Reference of UIImageview layer created in separate class
<p>Defined resumeLayer and PauseLayer method within the @interface and @end block in h file.</p>

<pre><code>@interface MainViewController : UIViewController

@property (nonatomic, retain) UIToolbar *toolbar;
@property (strong)AVAudioPlayer *audioPlayer;
@property (nonatomic, retain) NSTimer * timer;

- (void)resumeLayer:(CALayer *)layer;
- (void)pauseLayer:(CALayer *)layer;
@end
</code></pre>

<p>methods in m file</p>

<pre><code>-(void)pauseLayer:(CALayer*)layer
{
  CFTimeInterval pausedTime = [layer convertTime:CACurrentMediaTime() fromLayer:nil];
  layer.speed = 0.0;
  layer.timeOffset = pausedTime;
}

-(void)resumeLayer:(CALayer*)layer
{
  CFTimeInterval pausedTime = [layer timeOffset];
  layer.speed = 1.0;
  layer.timeOffset = 0.0;
  layer.beginTime = 0.0;
  CFTimeInterval timeSincePause = [layer convertTime:CACurrentMediaTime() fromLayer:nil] - pausedTime;
  layer.beginTime = timeSincePause;
 }
</code></pre>

<p>For calling resumeLayer and PauseLayer method in PlayPauseAction method</p>

<pre><code>-(void)playpauseAction:(id)sender {

if([audioPlayer isPlaying])
{
[sender setImage:[UIImage imageNamed:@"Play Icon.png"] forState:UIControlStateSelected];
[audioPlayer pause];
[self pauseTimer];
[self pauseLayer:ImageView.layer]; // Pause the CALayer of the UIImageView

}else{
[sender setImage:[UIImage imageNamed:@"pause.png"] forState:UIControlStateNormal];
[audioPlayer play];
[self resumeTimer];

if(isFirstTime == YES){
 self.timer = [NSTimer scheduledTimerWithTimeInterval:11.0
                                                  target:self
                                                selector:@selector(displayviewsAction:)
                                                userInfo:nil
                                                 repeats:NO];
  isFirstTime  = NO;
}
} 
}
</code></pre>

<p>ImageView is defined in class named Third</p>

<pre><code>   - (void)viewDidLoad
 {
// Displays UIImageView
UIImageView* ImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 5, 300, 235)];
self.view.backgroundColor = [UIColor brownColor];
// load all the frames of our animation
ImageView.animationImages = [NSArray arrayWithObjects:    
                             [UIImage imageNamed:@"3a.png"],
                             [UIImage imageNamed:@"3b.png"],
                             nil];
// all frames will execute in 24 seconds
ImageView.animationDuration = 24;
// start animating
[ImageView startAnimating];
ImageView.layer.borderWidth = 2;
ImageView.layer.borderColor = [[UIColor whiteColor]CGColor];    
[ImageView.layer setMasksToBounds:YES];
[ImageView.layer setCornerRadius:15.0f];
[self.view addSubview:ImageView]; }
</code></pre>

<p>I want to get reference of this ImageView.layer in MainViewController class to use in  </p>

<pre><code>  [self pauseLayer:ImageView.layer];
</code></pre>

<p>to pause imageview.layer animation</p>

<p>Now how can i get reference of this ImageView using</p>

<pre><code>  UIImageView *myImageView = [OtherClass getTheImageView];
</code></pre>

<p>to use following in playpauseAction to pause and resume Imageview  layer animation</p>

<pre><code>  [self pauseLayer:myImageView.layer]; // Pause the CALayer of the UIImageView
</code></pre>

<p>Any one can help me with thisHow to reference ImageView.layer in MainviewController</p>
