我正在尝试将自定义UIButton
放在自定义上,UIView
但UIButton
没有出现。虽然当我尝试打印UISubViews
myUIView
时,它会在那里显示UIButton
对象。
下面是我正在编写的将按钮放在我的自定义上的代码片段UIView
- (id)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if (self) {
self.backgroundColor = [UIColor blackColor];
self.headerLabel = [[UILabel alloc] initWithFrame:CGRectZero];
self.headerLabel.backgroundColor = [UIColor clearColor];
self.headerLabel.textColor = [UIColor whiteColor];
self.headerLabel.font = [UIFont systemFontOfSize:kApplicationHeaderTextFont];
[self addSubview:self.headerLabel];
self.actionButton = [UIButton buttonWithType:UIButtonTypeCustom];
self.actionButton.frame = CGRectZero;
[self addSubview:self.actionButton];
}
return self;
}
- (void)drawRect:(CGRect)iTotalRect{
if (self.actionButtonImage) {
self.actionButton.frame = CGRectMake(self.frame.size.width - self.actionButtonImage.size.width - 10.0, self.frame.size.height / 2 - self.actionButtonImage.size.height / 2, self.actionButtonImage.size.width, self.actionButtonImage.size.height);
[self.actionButton setImage:self.actionButtonImage forState:UIControlEventTouchUpInside];
}
有人知道我在做什么错吗?