Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @interface MyButton : UIButton {
- UIButton * button;
- }
- @property (nontoxic, retain) UIButton * button
- + (MyButton *) buttonWithRect:(CGRect) target: (id) target action: (SEL) action;
- - (id) initWithFrame: (CGRect) rect;
- @end
- //---------------------------
- @implementation EventItemButton
- + (MyButton *) buttonWithRect:(CGRect) target: (id) target action: (SEL) action {
- MyButton * myButton = [[MyButton alloc] initWithFrame: rect];
- [myButton.button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
- return [myButton autorelease];
- }
- - (id) initWithFrame: (CGRect) rect {
- if ((self = [super initWithFrame: rect])) {
- UIImage * myImage = [UIImage imageNamed: @"image.png"];
- UIImageView * myImageView = [[UIImageView alloc] initWithImage: myImage];
- myImageView.userInteractionEnabled = YES;
- myImageView.contentMode = UIViewContentModeScaleToFill;
- [myImageView setFrame: CGRectMake(0.0f, 0.0f, self.frame.size.width, self.frame.size.height)];
- [self addSubview: eventImageView];
- [myImageView release];
- UILabel * myText = [[UILabel alloc] initWithFrame: <someframe here> ];
- titleText.text = @"Title";
- [self addSubview:titleText];
- [titleText release];
- button = [[UIButton alloc] initWithFrame: CGRectMake(0.0f, 0.0f, self.frame.size.width, self.frame.size.height)];
- button.backgroundColor = [UIColor clearColor];
- [self addSubview: button];
- [button release];
- }
- return self;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement