An easy way to make a UILabel cover and exactly match the contents of a UITextField?

Distinctive features of UI ... I would like UILabel to replace UITextField after entering any user. Is there an easy way to do this, so when the UITextField is hidden, its value is replaced with a UILabel that doesn't seem to move ... appears to “set” into the background so to speak?

I managed to do this by pushing the margins around in IB and making the fonts the same, but as I slowly become comfortable with Cocoa, I was wondering if there could be some trick in the frameworks ?? Perhaps somehow extracting text from a UITextField?

+4
source share
1 answer

Setting the borderStyle property to UITextField to UITextBorderStyleNone should make it look very much like UILabel .

Basically, two UITextFieldDelegate methods are implemented:

 - (void)textFieldDidBeginEditing:(UITextField *)textField { textField.borderStyle = UITextBorderStyleRoundedRect; } - (void)textFieldDidEndEditing:(UITextField *)textField { textField.borderStyle = UITextBorderStyleNone; } 
+3
source

All Articles