
@property (nonatomic,assign) BOol keepGoing;@property (nonatomic,assign) BOol panRight;@property (nonatomic,strong) UIImageVIEw *imageVIEwA;@property (nonatomic,strong) UIImageVIEw *imageVIEwB;- (voID)getReady { // init theImage UIImage *theImage = [UIImage imagenamed:@"theImage.png"]; // get two copIEs of the image self.imageVIEwA = [[UIImageVIEw alloc] initWithImage:theImage]; self.imageVIEwB = [[UIImageVIEw alloc] initWithImage:theImage]; // place one in vIEw,the other,off to the right (for right to left motion) NSInteger direction = (self.panRight)? 1 : -1; self.imageVIEwA.frame = self.vIEw.bounds; self.imageVIEwB.frame = CGRectOffset(self.vIEw.bounds,direction*self.imageVIEwA.bounds.size.wIDth,0.0); [self.vIEw addSubvIEw:self.imageVIEwA]; [self.vIEw addSubvIEw:self.imageVIEwB]; self.keepGoing = YES;}- (voID)go { NSInteger direction = (self.panRight)? 1 : -1; CGfloat offsetX = -direction*self.imageVIEwA.bounds.size.wIDth; [UIVIEw animateWithDuration:1.0 delay:0.0 options:UIVIEwAnimationoptionCurvelinear animations:^{ self.imageVIEwA.frame = CGRectOffset(self.imageVIEwA.frame,offsetX,0); self.imageVIEwB.frame = CGRectOffset(self.imageVIEwB.frame,0); } completion:^(BOol finished) { if (self.keepGoing) { // Now B is where A began,so swap them and reposition B UIImageVIEw *temp = self.imageVIEwA; self.imageVIEwA = self.imageVIEwB; self.imageVIEwB = temp; self.imageVIEwB.frame = CGRectOffset(self.vIEw.bounds,direction*self.vIEw.bounds.size.wIDth,0.0); // recursive call,but we don't want to wind up the stack [self performSelector:@selector(go) withObject:nil afterDelay:0.0]; } }];} 要进行 *** 作,请设置panRight属性,然后调用[self getReady];和[自我去];
它将主要运行asynch.要使其停止,请设置self.keepGoing = NO;.
总结以上是内存溢出为你收集整理的ios – 在屏幕上水平滑动时循环的图像,看起来像无限滚动全部内容,希望文章能够帮你解决ios – 在屏幕上水平滑动时循环的图像,看起来像无限滚动所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)