自定义UILabel设置器

时间:2013-02-25 13:03:39

标签: ios objective-c uilabel

为什么不改变uilabel?

我创建了一些类,但不能覆盖setter

.h文件的代码

@interface ViewController : UIViewController
{
    UILabel * _lblName;
}
@property (retain, nonatomic) IBOutlet UILabel * lblName;

@end

.m文件的代码

@synthesize lblName = _lblName;

- (void)setLblName:(UILabel *)lblName{
if(![_lblName isEqual:lblName]){
[_lblName release];
_lblName = [lblName retain];}}

- (IBAction)didCustomBtnClick:(id)sender {
UILabel* lbl = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 0.0, 100.0, 30.0)];
lbl.text = @"Duck";
self.lblName = lbl;
[lbl release];}

0 个答案:

没有答案
相关问题