2011-02-23 31 views

回答

0
UIView *view = /*...*/; 
CGContextRef ctx = /*...*/; 

/* Shift center from UL corner to mid-x, mid-y. */ 
CGRect bounds = [view bounds]; 
CGFloat hx = bounds.size.width/2.0; 
CGFloat hy = bounds.size.height/2.0; 
CGContextTranslateCTM(ctx, hx, hy); 

/* y still increases down, and x to the right. */ 
/* if you want y to increase up, then flip y: */ 
CGContextScaleCTM(ctx, 1.0/*sx*/, -1.0/*sy*/); 
+0

thx,似乎這是我需要的 – 2011-02-23 14:41:11

0

默認情況下,(0,0)是在視圖的左上角。要移動此點視圖的中心,修改其邊界:

CGFloat width = self.bounds.size.width; 
CGFloat height = self.bounds.size.height; 
self.bounds = CGRectMake(-width/2.0, -height/2.0, width, height); 

確保重複這個計算時的角度的大小變化。