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
Post a Comment