IOS中,Button的currentTitle和titleLabel.text的使用

关于Button的两个property使用,官方参考如下:
// these are the values that will be used for the current state. you can also use these for overrides. a heuristic will be used to
// determine what image to choose based on the explict states set. For example, the ‘normal’ state value will be used for all states
// that don’t have their own image defined.

@property(nonatomic,readonly,retain) NSString *currentTitle;
// normal/highlighted/selected/disabled. can return nil

// return title and image views. will always create them if necessary. always returns nil for system buttons
@property(nonatomic,readonly,retain) UILabel *titleLabel NS_AVAILABLE_IOS(3_0);

其实currentTitle是对titleLable.text 的一个快速访问。
currentTitle只读
UIButton *but=[UIButton buttonWithType:UIButtonTypeCustom];
[but setTitle:@”测试一下” forState:UIControlStateNormal];
NSLog(@”%@”,but.currentTitle);
NSLog(@”%@”,but.titleLabel.text);

打印出的结果一样,同理,currentImage,currentBackgroundImage等都是一个快速访问的方法。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值