日々精進

新しく学んだことを書き留めていきます

UIButtonのtitleが表示されなくて困った

以下のコードを実行してもボタンのタイトルが表示されない。

        self.customButton = [BarButton buttonWithType:UIButtonTypeCustom];
        self.customButton.titleLabel.text = @"編集";

困っていろいろ調べたら、タイトルは専用のメソッドを使って設定するらしい。
正しくは以下。

        self.customButton = [BarButton buttonWithType:UIButtonTypeCustom];
        [self.customButton setTitle:@"編集" forState:UIControlStateNormal];

あーそういえばあったなこういうメソッド。。
てかこのインタフェースは良くないと思います!(キリッ)