Xcode5.0.2中带有圆角的按钮css button 圆角是怎么设置才出来

53493人阅读
//login button
UIButton *_loginB
@property (strong,nonatomic)UIButton *loginB
// .m 中实现设置按钮
@synthesize loginBtn = _loginB//使用备份变量名
//设置按钮的
self.loginBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
buttonWithType:
定义button按钮的外形
六种定义button类型: 下面有图解
UIButtonTypeCustom = 0,
UIButtonTypeRoundedRect,
四个角是圆弧
UIButtonTypeDetailDisclosure,
UIButtonTypeInfoLight,
UIButtonTypeInfoDark,
UIButtonTypeContactAdd,
//定义button按钮在frame上的坐标(位置),和这个按钮的宽/高
self.loginBtn.frame = CGRectMake(40, 200, 80, 30);
[self.loginBtn setTitle:@&Login& forState:UIControlStateNormal];
常用的属性:
设置button按钮的名称
setImage: [UIImage imageNamed:@&图名&]
setTitleColor:[UIColor redColor]
设置字体颜色
forState 设置 按钮点击前后的状态
: 下有图解
UIControlStateHighlighted
UIControlStateSelected
UIControlStateDisabled
UIControlStateNormal
// 为按钮添加一个动作
如果点击的话执行的方法
[self.loginBtn addTarget:self action:@selector(Login:) forControlEvents:UIControlEventTouchUpInside];
//把button控件添加到view中显示
[self.view addSubview:self.loginBtn];
//执行动作的方法
-(IBAction)Login:(id)
六种定义button类型:&
&& & UIButtonTypeCustom = 0,& &无类型
&& & UIButtonTypeRoundedRect,& &四个角是圆弧 &型的 &&
&& & UIButtonTypeDetailDisclosure & &
&& & UIButtonTypeInfoLight & &
&& & UIButtonTypeInfoDark & &
&& & UIButtonTypeContactAdd & &
forState&设置&按钮点击前后的状态&&&
& & & & 点击前 & & & & & & & & & & & & & & & & & & & & 点击后
UIControlStateHighlighted
UIControlStateSelected &&
UIControlStateDisabled &&
&&& &&UIControlStateNormal & &&
UIButtonTypeRoundedRect 设置为这个属性,是可以满足我们普通情况下的按钮圆角,当我们在button上添加背景图片和背景颜色的时候就会发现,这个属性并不适用,因为现在的button已经不是圆角的了,它显示的是图片的形状,当设置背景颜色设置为UIButtonTypeCustom属性才可以显示出来。所以我们需要用UIButton控件的其它属性来满足我们的需求
UIButton *
[btn.layer setMasksToBounds:YES];
[btn.layer setCornerRadius:10.0];//设置矩形四个圆角半径
[btn.layer setBorderWidth:1.0];//边框宽度
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:960688次
积分:10283
积分:10283
排名:第877名
原创:201篇
评论:295条
(1)(2)(1)(4)(1)(2)(5)(3)(4)(5)(4)(6)(2)(7)(2)(2)(19)(9)(10)(8)(36)(22)(24)(23)Xcode5.0.2中带有圆角的按钮button是怎么设置才出来_百度知道
Xcode5.0.2中带有圆角的按钮button是怎么设置才出来
提问者采纳
你说的这个。UIButton * button= [UIButton buttonWithType?已经弃用 了。。。。 苹果审核不通过的:UIButtonTypeRoundedRect ]
其他类似问题
为您推荐:
圆角的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁xcode 在storyboard怎样设置button的圆角边框_百度知道
xcode 在storyboard怎样设置button的圆角边框
不希望用代码实现
你自己网上下载一套好看的圆角图片,设为button的背景不就行了?(selecte穿袱扁惶壮耗憋同铂括d和normal各设置一张)
其他类似问题
为您推荐:
xcode的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁主题 : Xcode5.0.2中带有圆角的按钮button是怎么设置才出来呢
级别: 新手上路
可可豆: 216 CB
威望: 261 点
在线时间: 128(时)
发自: Web Page
Xcode5.0.2中带有圆角的按钮button是怎么设置才出来呢&&&
Xcode5.0.2中带有圆角的按钮button是怎么设置才出来呢………..
级别: 侠客
UID: 69637
可可豆: 861 CB
威望: 811 点
在线时间: 319(时)
发自: Web Page
uibutton *btn=[uibutton buttonwithtype:]有个枚举是圆角类型
级别: 新手上路
可可豆: 20 CB
威望: 1 点
在线时间: 0(时)
发自: Web Page
UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
级别: 侠客
UID: 155386
可可豆: 300 CB
威望: 393 点
在线时间: 207(时)
发自: Web Page
IOS7 应该显示不出来!还是用图片吧!
级别: 新手上路
可可豆: 0 CB
威望: 1 点
在线时间: 65(时)
发自: Web Page
iOS 7 都是直角,那个类型都一样,唉,同意楼上
级别: 新手上路
可可豆: 4 CB
威望: 4 点
在线时间: 60(时)
发自: Web Page
UIButton *roundBtn = [UIButton buttonWithType:UIButtonTypeCustom];
roundBtn.frame = CGRectMake(100, 100, 50, 50);
roundBtn.backgroundColor = [UIColor redColor];//为了看得明显
//设置cornerRadius
_roundBtn.layer.cornerRadius = 10.0;
级别: 新手上路
UID: 391415
可可豆: 20 CB
威望: 15 点
在线时间: 37(时)
发自: Web Page
楼上正解,找了很久了
关注本帖(如果有新回复会站内信通知您)
iPhone5的分辨率? 正确答案:
发帖、回帖都会得到可观的积分奖励。
按"Ctrl+Enter"直接提交
关注CocoaChina
关注微信 每日推荐
扫一扫 浏览移动版

我要回帖

更多关于 css button 圆角 的文章

 

随机推荐