Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to put background image to a text field and text view in iphone?

Although I have set the background image property in UITextField. It doesn't apply.I didn't use any coding. I have just selected an image.png file as the backround image using Interface Builder. So,How to do it ? And there is no background image property in UITextView. So,How can I add background image to textView ? Thanks for the help.

like image 581
harshiYL Avatar asked Nov 28 '22 17:11

harshiYL


2 Answers

Please refer to the documentation of UITextField and you will find the following:

The default value for this property is UITextBorderStyleNone. If the value is set to the UITextBorderStyleRoundedRect style, the custom background image associated with the text field is ignored.

In Interface Builder, just below the place where you set the background image, there should be an option to select a border style, by default it is selected to RoundedRect, select another style and you can immediately see the background image.

like image 64
Srikanth Avatar answered Dec 05 '22 15:12

Srikanth


Use this

textField.backgroundColor = [UIColor colorWithPatternImage:myImage];

where "myImage" is your image.

like image 42
Yurec Antidipresant Avatar answered Dec 05 '22 15:12

Yurec Antidipresant