I want to create special text fields, with different background images, colors or sizes. How can I do that?
Asked
Active
Viewed 2,156 times
0
-
2Can you elaborate, do you wish to extend `UITextField` or programatically set properties [see this](http://www.icodeblog.com/2010/01/04/uitextfield-a-complete-api-overview/) or use interface builder to set properties? – T I Jan 17 '12 at 12:55
-
@TomIngram : nice link. Why don't you put it in answers? – Yama Jan 17 '12 at 12:59
-
thanks I use this way, http://stackoverflow.com/questions/1861527/uitextfield-border-color – Hacer sengul Akac Jan 17 '12 at 13:16
2 Answers
0
In IB, drag a View into your current view, set it's Custom Class
to your own class (probably an UITextField subclass) and start adding your own images etc.

ott--
- 5,642
- 4
- 24
- 27
0
Appologies in advance if my example code has errors, I have not done much cocoa/objective-c in a while but here are three approaches to your problem.
Programatically setting properties in say a UIView
@interface MYView: UIView
{
}
@implementation MYView
{
- (void) loadView {
UITextField * text = [[UITextField alloc] init];
text.frame = CGRectMake(100, 170, 100, 30);
[text setFont:[UIFont fontWithName:@"Times New Roman" size:30]];
[text setBorderStyle:UITextBorderStyleBezel];
[self.view addSubview:text];
}
}
Through inheritance - which you can use in a view as above (maybe also use from IB)
@interface MYTextFied: UITextField
{
}
@implementation MYTextField
{
- (void) init {
self = [super init];
if (self != nil) {
[self setFont:[UIFont fontWithName:@"Times New Roman" size:30]];
[self setBorderStyle:UITextBorderStyleBezel];
}
return self;
}
}
In IB just click around until you find the appropriate menu/pane or take a look at this

T I
- 9,785
- 4
- 29
- 51