Ios 如果在viewDidLoad之后添加,则CALayer不可见
我有一个名为Ios 如果在viewDidLoad之后添加,则CALayer不可见,ios,objective-c,iphone,core-animation,calayer,Ios,Objective C,Iphone,Core Animation,Calayer,我有一个名为TiledScrollViewController的类,它与UIScrollView完全无关。在该视图控制器中,我试图通过调用newCylon将CALayer从应用程序其他位置的回调添加到视图控制器的bImageView属性中。对赛昂人。这是一个愚蠢的应用程序,但这是一个重要的问题 这就是我创建新赛昂人图层的方式 -(CALayer *)newCALayerWithNSString:(NSString *)imageName andCATransf
TiledScrollViewController
的类,它与UIScrollView
完全无关。在该视图控制器中,我试图通过调用newCylon
将CALayer从应用程序其他位置的回调添加到视图控制器的bImageView
属性中。对赛昂人。这是一个愚蠢的应用程序,但这是一个重要的问题
这就是我创建新赛昂人图层的方式
-(CALayer *)newCALayerWithNSString:(NSString *)imageName
andCATransform3D:(CATransform3D)transform
andCGPoint:(CGPoint)point {
CALayer *outputLayer = [CALayer layer];
UIImage *img = [UIImage imageNamed:imageName];
outputLayer.backgroundColor = [UIColor colorWithPatternImage:img].CGColor;
[outputLayer setBounds:CGRectMake(0.0, 0.0, img.size.width, img.size.height)];
outputLayer.transform = transform;
[outputLayer setPosition:point];
[outputLayer setZPosition:5.0];
return outputLayer;
}
下面是我在newCylon
中对它的称呼
-(CALayer *)newCylon{
NSLog(@"NEW CYLON");
CALayer *cylon = [self newCALayerWithNSString:@"Cylon"
andCATransform3D:CATransform3DMakeScale(.3, -.3, .3)
andCGPoint:CGPointMake(.5*screenWidth,0)];
[self.bgImageView.layer addSublayer:cylon]; // this works, but I don't see anything
[self moveCylon:cylon];
return cylon;
}
现在。我有一个赛昂人CALayer
,它可以显示和动画,因为我在viewDidLoad
中调用[self-newCylon]
。但是如果我打电话给其他任何地方的新赛昂人,什么都不会出现。我可以通过[self.bgImageView.layer sublayers]
验证子层
阵列的大小是否在变化。但除了第一个赛昂人,屏幕上什么也没有出现
我做错了什么?在我的
newCylon
方法的末尾添加[catransation flush]
修复了所有问题。你应该根据参数的用途而不是类型来命名参数。