ios中檢視座標系的轉換主要用到uiview的四個api:
座標系轉換的實質是: 更改座標系的原點.
- (cgpoint)convertpoint:(cgpoint)point toview:(nullable uiview *)view;
- (cgpoint)convertpoint:(cgpoint)point fromview:(nullable uiview *)view;
- (cgrect)convertrect:(cgrect)rect toview:(nullable uiview *)view;
- (cgrect)convertrect:(cgrect)rect fromview:(nullable uiview *)view;
**:
#import "viewcontroller.h"
@inte***ce
viewcontroller ()
@property(nonatomic,strong)uiview *redview;
@property(nonatomic,strong)uiview *blueview;
@property(nonatomic,strong)uiview *yellowview;
@property(nonatomic,strong)uiview *orangeview;
@end
@implementation
viewcontroller
- (void)viewdidload
- (void)touchesbegan:(nsset*)touches withevent:(uievent *)event
@end
列印結果:
2016-04-15 15:51:33.543 座標系轉換[2744:154111] 橘色view在父控制項中的frame = , }
2016-04-15 15:51:33.544 座標系轉換[2744:154111] 橘色view在藍色view中的frame1 = , }
2016-04-15 15:51:33.544 座標系轉換[2744:154111] 橘色view在藍色view中的frame2 = , }
2016-04-15 15:51:33.544 座標系轉換[2744:154111] 橘色view在紅色view中的frame = , }
2016-04-15 15:51:33.544 座標系轉換[2744:154111] 橘色view在控制器view中的frame = , }
2016-04-15 15:51:33.544 座標系轉換[2744:154111] 黃色view在控制view中的frame = , }
ios座標系轉換
1.cgrect convertrect cgrect rect toview uiview view 文件解釋 converts a rectangle from the receiver s coordinate system to that of another view.意思就是說把乙個矩形...
iOS座標系轉換
把乙個矩形從接收者的座標系轉換到另乙個檢視 view 的座標系中.注 若view引數為空,則轉換為視窗 window 的座標系 接收者與view都必須是同一視窗 window 的物件。下面是把選中的from單元的frame轉換為相對於當前視窗座標系的座標 預設情況下frame是以父控制項 windo...
iOS座標系轉換總結
座標系轉換方法 cgpoint convertpoint cgpoint point toview nullable uiview view cgpoint convertpoint cgpoint point fromview nullable uiview view cgrect convert...