
- (voID)vIEwDIDLoad{ [super vIEwDIDLoad]; UIImageVIEw *imageVIEw = [[UIImageVIEw alloc] initWithFrame:CGRectMake(20,122,38,38)]; imageVIEw.image = [UIImage imagenamed:@"settings1.png"]; [self.vIEw addSubvIEw:imageVIEw]; CABasicAnimation *spin; spin = [CABasicAnimation animationWithKeyPath:@"transform.rotation"]; spin.fromValue = [NSNumber numberWithfloat:0]; spin.tovalue = [NSNumber numberWithfloat:((360*M_PI)/180)]; spin.duration = 4; spin.repeatCount = 10*1000; [imageVIEw.layer addAnimation:spin forKey:@"360"];解决方法 这可能是因为你试图在vIEwDIDLoad中启动动画.我建议重新组织你的代码,使你在vIEwDIDLoad中创建图像视图实例,但是等到vIEwDIDAppear:被调用以实际启动动画. @property (strong,nonatomic) UIImageVIEw *imageVIEw;
然后
- (voID)vIEwDIDLoad{ [super vIEwDIDLoad]; self.imageVIEw = [[UIImageVIEw alloc] initWithFrame:CGRectMake(20,38)]; self.imageVIEw.image = [UIImage imagenamed:@"settings1.png"]; [self.vIEw addSubvIEw:self.imageVIEw];}- (voID)vIEwDIDAppear:(BOol)animated{ [super vIEwDIDAppear:animated]; CABasicAnimation *spin = [CABasicAnimation animationWithKeyPath:@"transform.rotation"]; spin.fromValue = [NSNumber numberWithfloat:0]; spin.tovalue = [NSNumber numberWithfloat:((360*M_PI)/180)]; spin.duration = 4; spin.repeatCount = 10*1000; [self.imageVIEw.layer addAnimation:spin forKey:@"360"];} 总结 以上是内存溢出为你收集整理的xcode – CABasicAnimation无法使用UIImageView全部内容,希望文章能够帮你解决xcode – CABasicAnimation无法使用UIImageView所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)