I am trying to put a custom UIButton on a custom UIView but the UIButton is not appearing. Although when I try to print UISubViews of my UIView, it shows the UIButton object there.
Below is the piece of the code I am writing to put the button on my custom 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];
}
Anybody know what I am doing wrong?
so I found what you need!!
maybe this:
and now u can add your options! try it!
here is something from part of my app that u can see what i mean:
well I found the final solution for you: