【发布时间】:2017-06-23 17:08:21
【问题描述】:
我有一个简单的自定义 UIView 类和一个关联的 xib 文件,其中包含一个 ImageView,我想在视图初始化时开始旋转。
下面是我的 UIView 代码。使用断点我可以确认代码被调用:
#import "PinWithTimeView.h"
#import "QuartzCore/QuartzCore.h"
@implementation PinWithTimeView
- (id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self) {
CABasicAnimation *fullRotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
fullRotation.fromValue = [NSNumber numberWithFloat:0];
fullRotation.toValue = [NSNumber numberWithFloat:((360*M_PI)/180)];
fullRotation.duration = 6;
fullRotation.repeatCount = 10;
[self.rotateCircle.layer addAnimation:fullRotation forKey:@"360"];
}
return self;
}
@end
但是,当我这样初始化时,ImageView 永远不会旋转。谁能告诉我为什么?
PinWithTimeView *pinMarker = [[[NSBundle mainBundle] loadNibNamed:@"PinWithTimeView" owner:self options:nil] firstObject];
【问题讨论】:
标签: ios objective-c uiview