2013年9月12日 星期四

UIButton改text要用setTitle!

self.nameButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[self.nameButton addTarget:self
               action:@selector(nameButtonClicked:)
     forControlEvents:UIControlEventTouchUpInside];
[self.nameButton setTitle:@"Show Target Name" forState:UIControlStateNormal];
 self.nameButton.frame = CGRectMake(60.0, 20.0, 200.0, 80.0);
 [self.view addSubview:self.nameButton];

 //UIButton改text要用setTitle!
//而不是用self.nameButton.titleLabel.text,因為它是readonly

沒有留言:

張貼留言