這應該是一個簡單的,基本上我有幾個路徑與核心圖形繪製,我想能夠旋轉它們(爲了方便)。我試過使用CGContextRotateCTM(上下文);但它沒有旋轉任何東西。我錯過了什麼嗎?核心圖形旋轉路徑
下面是這個拉絲/填充你的身材翻譯原籍之前的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, 13.5, 4.3, 4.3));
CGContextFillRect(context, CGRectMake(13.5, 26.2, 4.3, 4.3));
CGContextRotateCTM(context, M_PI/4);
}
你能否包含一些源代碼? CGContextRotateCTM(上下文)是正確的功能,但如果您不包含任何代碼,則很難看到代碼中是否有錯誤! – 2010-04-06 15:46:38
我更新了原始文章以包含源代碼,任何幫助將不勝感激! – 2010-04-06 17:11:54