私は UIButton をサブクラス化しています。ボタンの種類を Round Rect に設定したいのです。
ボタン.h
@interface Button : UIButton {}
- (void)initialize;
@end
ボタン.m
@implementation Button
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self initialize];
}
return self;
}
-(id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if(self){
[self initialize];
}
return self;
}
- (void)initialize
{
self.titleLabel.font = [UIFont systemFontOfSize:20];
self.titleLabel.textColor = [UIColor redColor];
self.titleLabel.textAlignment = UITextAlignmentCenter;
//[UIButton buttonWithType:UIButtonTypeRoundedRect];
}
@end
ここで私は試し[UIButton buttonWithType:UIButtonTypeRoundedRect]
ましたが、うまくいきません。誰でもそれを機能させる方法を提案できますか?
以前の多くの投稿で、UIButton のサブクラス化は推奨されないと言われていましたが、開発者のドキュメントにはサブクラス化しないことについて言及されていないという事実を知っています。