ios - In UIKit, how can I add a UILabel as a subview to a UITextField so that is positioned exactly where the text will be? -


i want add uilabel subview uitextfield. should positioned @ exact same coordinates normal text contents. (i aware of uitextfield.placeholder, not fit requirements.)

i have created class inherits uitextfield , assigned text field in storyboard. have added following in initwithcoder method:

placeholderlabel = [[uilabel alloc] init]; // set font, color, text  [placeholderlabel sizetofit]; // rect useless me :( cgrect frame = [self textrectforbounds:placeholderlabel.bounds];  [self addsubview:placeholderlabel]; 

i use initwithframe method, instead of init, or set uilabel's frame property need know gcrect. need calculate hand based on uitextfield's height, paddings, font size, , possible left view etc?


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -