【发布时间】:2014-04-19 08:21:08
【问题描述】:
我有UITextField 的这个子类,我想将属性设置为UITextField 的背景颜色、边框等。我不知道,如果我使用正确的方法,因为当我将这个类用于UItextField 时,UITextField 不会改变。我必须在哪种方法中声明这个属性?
#import "defaultUITextField.h"
@implementation defaultUITextField
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.delegate = self;
[self setBackgroundColor:([UIColor redColor])];
UIColor *borderColor = [UIColor colorWithRed:233.0/255.0 green:233.0/255.0 blue:233.0/255.0 alpha:233.0/255.0];
self.leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 5, 20)];
self.leftViewMode = UITextFieldViewModeAlways;
self.layer.borderColor = [borderColor CGColor];
self.layer.borderWidth = 1.0f;
}
return self;
}
@end
【问题讨论】:
标签: objective-c uitextfield subclass uiappearance