边框(UIbutton UItextfiled)

来源:互联网 发布:语音聊天赚钱软件 编辑:程序博客网 时间:2024/06/05 01:10

UIButton *back = [UIButton buttonWithType:UIButtonTypeCustom];
back.frame = CGRectMake(login.frame.origin.x + login.frame.size.width + 59 * ScreenWidth, login.frame.origin.y, 115 * ScreenWidth, 30 * ScreenHeigth);
[back setTitle:@”返回首页” forState:UIControlStateNormal];
[back setTitleColor: [UIColor colorWithRed:37 / 255.0 green:37 / 255.0 blue:37 / 255.0 alpha:1.0] forState:UIControlStateNormal];
back.layer.cornerRadius = 2 * ScreenWidth;
back.layer.masksToBounds = YES;
back.font = [UIFont systemFontOfSize:15.0 * ScreenWidth];
//设置边框宽度和颜色
back.layer.borderColor = [UIColor colorWithRed:50 / 255.0 green:50 / 255.0 blue:50 / 255.0 alpha:1.0].CGColor;
[back.layer setBorderWidth:0.5 * ScreenWidth];
back.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
back.backgroundColor = [UIColor whiteColor];
[back addTarget:self action:@selector(backClicked:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:back];

self.text = [[UITextField alloc] initWithFrame:CGRectMake(20 * ScreenWidth, 40 * ScreenHeigth, [UIScreen mainScreen].bounds.size.width - 40 * ScreenWidth, 45 * ScreenHeigth)];
self.text.delegate = self;
self.text.textColor = [UIColor colorWithRed:100 / 255.0 green:100 / 255.0 blue:100 / 255.0 alpha:1.0];
self.text.backgroundColor = [UIColor colorWithRed:255 / 255.0 green:255 / 255.0 blue:255 / 255.0 alpha:1.0];
self.text.keyboardType = UIKeyboardTypePhonePad;
self.text.placeholder = @”手机号码”;

//设置圆角self.text.layer.cornerRadius = 5 * ScreenWidth;self.text.layer.borderWidth = 1 * ScreenWidth;self.text.layer.borderColor = [[UIColor colorWithRed:200 / 255.0 green:200 / 255.0 blue:200 / 255.0 alpha:1.0] CGColor];[self.view addSubview:self.text];//设置字体距离左边框的距离self.text.leftView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 70 * ScreenWidth, 0)];self.text.leftViewMode = UITextFieldViewModeAlways;
0 0
原创粉丝点击