Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Hey guys, I finally resolve my problem. I subclassed <code>UIView</code> and added two <code>UIImageView</code>s and an <code>UIButton</code> to it. The animation is perfectly good now!</p> <p>Here is the code:</p> <p>.h</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface NNAnimatableButton : UIView { UIImageView *backgroundImageView; UIImageView *imageView; UIButton *button; } @property (nonatomic, retain) UIImageView *backgroundImageView; @property (nonatomic, retain) UIImageView *imageView; @property (nonatomic, retain) UIButton *button; @end </code></pre> <p>.m</p> <pre><code>#import "NNAnimatableButton.h" @implementation NNAnimatableButton @synthesize backgroundImageView, imageView, button; - (id)initWithFrame:(CGRect)frame { if ((self = [super initWithFrame:frame])) { CGRect rect = CGRectMake(0.0f, 0.0f, frame.size.width, frame.size.height); NSUInteger autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleBottomMargin; // Initialization code. backgroundImageView = [[UIImageView alloc] initWithFrame:rect]; backgroundImageView.autoresizingMask = autoresizingMask; imageView = [[UIImageView alloc] initWithFrame:rect]; imageView.autoresizingMask = autoresizingMask; imageView.contentMode = UIViewContentModeCenter; button = [UIButton buttonWithType:UIButtonTypeCustom]; button.autoresizingMask = autoresizingMask; [button setFrame:rect]; [self addSubview:backgroundImageView]; [self addSubview:imageView]; [self addSubview:button]; [backgroundImageView release]; [imageView release]; } return self; } - (void)dealloc { [backgroundImageView release]; [imageView release]; [button release]; [super dealloc]; } @end </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload