IOS-Button CurrentTitle and titleLabel 使用

Code:    

    UIButton *btnSignOn = [UIButtonbuttonWithType:UIButtonTypeCustom];

    btnSignOn.frame = CGRectMake(100, 100, 150, 150);

    btnSignOn.center = CGPointMake(175, 175);

    [btnSignOn addTarget:selfaction:@selector(buttonSignOn:) forControlEvents:UIControlEventTouchUpInside];

    btnSignOn.backgroundColor = [UIColorbrownColor];

    [btnSignOn setTitle:@"GOOD"forState:UIControlStateNormal];    //button上CurrenTitle显示为GOOD

//    btnSignOn.titleLabel.text = @"btnSignOn";                            //

//    btnSignOn.titleLabel

//    btnSignOn.titleLabel.textColor = [UIColorredColor];

    btnSignOn.tintColor = [UIColorgreenColor];

    [self.view addSubview:btnSignOn];

    [btnSignOn release];

currentTitle 和titlelabel 不一样。按钮上显示的是CurrnetTitle,而不是titlelabel。

http://sandfly.net.nz/blog/2010/02/uibutton-titlelabel-is-not-as-useful-as-it-looks/

posted on 2012-08-19 19:16  tx天翔  阅读(1456)  评论(0编辑  收藏  举报