Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Simen Anthonsen
1,097 PointsAdd background image to UITextfield
In order to add a background image to an UITextfield, i have to change the standard border style to square. How do you add a background image without having to change the standard border style?
2 Answers
Martin Foldyna
10,359 PointsHello, try to make output of this UITextfield. And than (name of the output).background = UIImage(named: "nameOfTheImage.jpg/png…");
Linus Liang
1,460 PointsI found a quick workaround where I add a UITextField with backgroundColor set as UIColor.clearColor() as a subview to a UIImageView. You can make the UIImageView have rounded corners by setting UIImageView.layer.cornerRadius.
Simen Anthonsen
1,097 PointsSimen Anthonsen
1,097 PointsThat´s how I do it, but it only works if i change the border style to square. The picture does not show up with the standard UITextfield border style.