关于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等都是一个快速访问的方法。