ios之UIbutton

这是第一次与大家分享,如果不能帮到你请见谅。

btn的创建

btn的形状
UIButton *Btn = [UIButton buttonWithType:UIButtonTypeCustom];

这是btn的几个按钮类型

{

    UIButtonTypeCustom = 0,                         // 没有按钮类型
    UIButtonTypeSystem                         // 标准系统按钮

    UIButtonTypeDetailDisclosure,
    UIButtonTypeInfoLight,
    UIButtonTypeInfoDark,
    UIButtonTypeContactAdd,
    
    UIButtonTypeSystem,  

}

btn的位置
    Btn.
frame = CGRectMake(84, 176, 127, 46);
btn文字居中
    Btn.
titleLabel.textAlignment = NSTextAlignmentCenter;
这是字体靠左右和居中
{
    NSTextAlignmentLeft     
    NSTextAlignmentCenter   
    NSTextAlignmentRight   

}
btn上面添加文字
    [
Btn setTitle:@"创建btn" forState:UIControlStateNormal];
btn设置字体  这里我设置了字体和大小
    Btn.
titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:18];
btn点击方法
    [
Btn addTarget:self action:@selector(点击方法) forControlEvents:UIControlEventTouchUpInside];
btn字体的颜色
    [Btn setTitleColor:[UIColor whiteColor] forState:UIControlStateReserved];
btn的圆角
    Btn.
layer.cornerRadius = 4.0;
btn的背景色
    Btn.
backgroundColor = [UIColor redColor];
btn高亮显示
    Btn.
showsTouchWhenHighlighted = YES;
btn添加在view上面
    [
self.view addSubview
:Btn];

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值