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