Code/XCODE

Xcode - button title 변경 및 체크 박스 구현

sidcode 2012. 2. 15. 12:45
StoryBoard
 - Button 삽입 ( 체크 박스 사이즈 )
 - Inspector ( 연결 들 )
    - Touch Up Inside - ViewContorller - chagneButtonText (연결 )
    - Referencing Outlets - ViewContorller - autoLoginButton (연결 )

참조. 1

 



구현
ViewController.h

@interface ViewController : UIViewController{

    IBOutlet UIButton *autoLoginButton; 

}


@property (retain, nonatomic) UIButton *autoLoginButton;


- (IBAction)changeButtonText:(id)sender;


@end



ViewController.m

@synthesize autoLoginButton;



- (void)didReceiveMemoryWarning

{

    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.

}


- (IBAction)changeButtonText:(id)sender{

    if(autoLoginButton.titleLabel.text == @"V"){

        [autoLoginButton setTitle:@"" forState: UIControlStateNormal];   

        autoLoginButton.titleLabel.text = @"";

    } else {

        [autoLoginButton setTitle:@"V" forState: UIControlStateNormal];

    }

    

    NSLog(autoLoginButton.titleLabel.text);

}




- 버튼 클릭스 화면 변화

1. 초기
 
2. 체크 
 
3. 초기