Xcode (objective-c,swift)、Android開発でボタンの文字設定
ボタンの文字を設定(変更)する方法です。
Objective-c
1 | @implementation ViewController |
2 | @synthesize start_btn; |
3 |
4 | //================== |
5 | - ( void )viewDidLoad |
6 | { |
7 |
8 | //途中省略 |
9 | [start_btn setTitle: @"開始" forState:UIControlStateNormal]; |
10 | } |
Swift
1 | class ViewController: UIViewController { |
2 |
3 | @IBOutlet weak var str_btn: UIButton! |
4 |
5 | //================== |
6 | - (void)viewDidLoad |
7 | { |
8 | //途中省略 |
9 |
10 | //ボタンのテキストを”開始”にする |
11 | self .str_btn.setTitle( "開始" , forState: .Normal) |
12 | } |
Android
1 | //ボタンのテキストを”開始”にする |
2 | str_btn.setText( "開始" ); |