小编Sco*_*dyk的帖子

核心图形旋转路径

这应该是一个简单的,基本上我有几个用核心图形绘制的路径,我希望能够旋转它们(为方便起见).我尝试过使用CGContextRotateCTM(context); 但它不会旋转任何东西.我错过了什么吗?

这是drawRect的来源

- (void)drawRect:(CGRect)rect {
CGContextRef context = UIGraphicsGetCurrentContext();

CGContextSetLineWidth(context, 1.5);
CGContextSetStrokeColorWithColor(context, [UIColor whiteColor].CGColor);
CGContextSetShadow(context, CGSizeMake(0, 1), 0);

CGContextBeginPath(context);

CGContextMoveToPoint(context, 13.5, 13.5);
CGContextAddLineToPoint(context, 30.5, 13.5);
CGContextAddLineToPoint(context, 30.5, 30.5);
CGContextAddLineToPoint(context, 13.5, 30.5);
CGContextAddLineToPoint(context, 13.5, 13.5);

CGContextClosePath(context);

CGContextMoveToPoint(context, 26.2, 13.5);
CGContextAddLineToPoint(context, 26.2, 17.8);
CGContextAddLineToPoint(context, 30.5, 17.8);

CGContextMoveToPoint(context, 17.8, 13.5);
CGContextAddLineToPoint(context, 17.8, 17.8);
CGContextAddLineToPoint(context, 13.5, 17.8);

CGContextMoveToPoint(context, 13.5, 26.2);
CGContextAddLineToPoint(context, 17.8, 26.2);
CGContextAddLineToPoint(context, 17.8, 30.5);

CGContextStrokePath(context);

CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor);
CGContextSetShadowWithColor(context, CGSizeMake(0, 0), 0, [UIColor clearColor].CGColor);

CGContextFillRect(context, CGRectMake(26.2, 13.5, 4.3, 4.3));
CGContextFillRect(context, CGRectMake(13.5, …
Run Code Online (Sandbox Code Playgroud)

iphone core-graphics cgcontext

11
推荐指数
1
解决办法
5681
查看次数

核心动画回调

我正在使用核心动画在我的应用程序中的不同视图状态之间进行转换.但是,我需要找到一种在动画完成后执行不同任务的方法.我知道我可以实现委托方法并使用

- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag;
Run Code Online (Sandbox Code Playgroud)

回调,但是没有简单的方法来跟踪哪个动画结束.

我可以想到一些繁琐的解决方案,比如使用一系列标志和计数器,但是我想知道是否有更有效和实用的方法来解决这个问题.

有什么想法?

macos cocoa delegates core-animation callback

2
推荐指数
1
解决办法
1282
查看次数