iOS开发--UIButton 设置圆角 边框颜色 点击回调方法

 1 UIButton *signBtn = [UIButton buttonWithType:UIButtonTypeCustom];
 2 signBtn.frame = CGRectMake(0, 0, 80, 40);
 3 [signBtn.layer setMasksToBounds:YES];
 4 [signBtn.layer setCornerRadius:10.0]; //设置矩形四个圆角半径
 5 [signBtn.layer setBorderWidth:1.0]; //边框宽度
 6 CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
 7 CGColorRef colorref = CGColorCreate(colorSpace,(CGFloat[]){ 1, 0, 0, 1 });
 8 [signBtn.layer setBorderColor:colorref];//边框颜色
 9 [signBtn setTitle:@"还  原" forState:UIControlStateNormal];//button title
10 [signBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];//title color
11 [signBtn addTarget:self action:@selector(buttonDonwRecover:) forControlEvents:UIControlEventTouchUpInside];//button 点击回调方法
12 signBtn.backgroundColor = [UIColor whiteColor];
时间: 2024-10-07 21:40:13

iOS开发--UIButton 设置圆角 边框颜色 点击回调方法的相关文章

UIButton 设置圆角 边框颜色 点击回调方法

UIButton *signBtn = [UIButton buttonWithType:UIButtonTypeCustom]; signBtn.frame = CGRectMake(0, 0, 80, 40); [signBtn.layer setMasksToBounds:YES]; [signBtn.layer setCornerRadius:10.0]; //设置矩形四个圆角半径 [signBtn.layer setBorderWidth:1.0]; //边框宽度 CGColorSpa

uibutton 设置圆角边框

[m_selectUserBtr.layer setMasksToBounds:YES]; [m_selectUserBtr.layer setCornerRadius:3]; //设置矩形四个圆角半径 [m_selectUserBtr.layer setBorderWidth:1.0]; //边框宽度 UIColor *ccc = [UIColor colorWithRed:1.00 green:1.00 blue:1.00 alpha:.35]; CGColorRef colorref =

ios开发storyboard设置圆角按钮

1.很多人都知道,通常设置一个 Button后者其他的UIView子类的圆角,需要使用如下的语句 <span style="font-family:SimSun;font-size:18px;">self.button.layer.cornerRadius=10;//即可 </span> <span style="font-family:SimSun;font-size:18px;"> </span> 说明:这会用到l

ios开发 之 设置多种文字颜色

 UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 300, 100)];     label.numberOfLines = 0;     label.center = self.view.center;          NSMutableAttributedString * str = [[NSMutableAttributedString alloc]initWithString:@"你说你最爱丁香花,因为你

Swift开发教程--设置圆角Button和圆角边框TextView

设置圆角Button button.layer.borderColor = UIColor.whiteColor().CGColor; button.layer.borderWidth = 2; button.layer.cornerRadius = 16; 设置圆角边框TextView inputTextView.layer.borderColor = UIColor(red: 60/255, green: 40/255, blue: 129/255, alpha: 1).CGColor; i

IOS 开发更改UITextField的Placeholder颜色

UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(100, 200, 200, 40)];    UIColor *color = [UIColor redColor]; textField.backgroundColor = [UIColor yellowColor]; textField.attributedPlaceholder = [[NSAttributedString alloc] initW

iOS开发中16进制颜色(html颜色值)字符串转为UIColor

//16进制颜色(html颜色值)字符串转为UIColor +(UIColor *) hexStringToColor: (NSString *) stringToConvert { NSString *cString = [[stringToConvert stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString]; // String should be

IOS -UIButton设置边框颜色

1.UIButton边框为浅灰色: CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB(); CGColorRef color = CGColorCreate(colorSpaceRef, (CGFloat[]){0.1,0,0,0.1}); [_username.layer setBorderWidth:2];//设置边界的宽度 [_username.layer setBorderColor:color];//设置边界的颜色

UIButton设置圆角和边框及边框颜色

[box.actionButton.layer setMasksToBounds:YES]; [box.actionButton.layer setCornerRadius:10.0]; //设置矩形四个圆角半径 //边框宽度 [box.actionButton.layer setBorderWidth:1.0]; //边框颜色 CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGColorRef colorref = CG