码迷,mamicode.com
首页 > 其他好文 > 详细

改变文字输入框背景

时间:2014-12-02 17:12:03      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:style   blog   io   ar   color   sp   on   div   log   

代码:

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    UITextField *textField=[[UITextField alloc]initWithFrame:CGRectMake(50, 100, 200, 50)];
    textField.backgroundColor=[UIColor redColor];
    textField.delegate=self;
    [self.view addSubview:textField];
    
}
#pragma -mark -UITextFieldDelegate
-(BOOL) textFieldShouldBeginEditing:(UITextField *)textField{
    [textField setBackground:[UIImage imageNamed:@"1.jpg"]];
    return YES;
}

-(void) textFieldDidEndEditing:(UITextField *)textField{
    [textField setBackground:[UIImage imageNamed:@"2.jpg"]];
}
-(BOOL)textFieldShouldReturn: (UITextField *)TextField{
    [TextField resignFirstResponder];
    return YES;
}

 

改变文字输入框背景

标签:style   blog   io   ar   color   sp   on   div   log   

原文地址:http://www.cnblogs.com/yang-guang-girl/p/4137818.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!