iOS開發筆記 UIView中的座標轉換

2021-06-27 16:04:29 字數 1431 閱讀 5102

[objc]view plain

copy

// 將畫素point由point所在檢視轉換到目標檢視view中,返回在目標檢視view中的畫素值

- (cgpoint)convertpoint:(cgpoint)pointtoview

:(uiview

*)view;  

// 將畫素point從view中轉換到當前檢視中,返回在當前檢視中的畫素值

- (cgpoint)convertpoint:(cgpoint)pointfromview

:(uiview

*)view;  

// 將rect由rect所在檢視轉換到目標檢視view中,返回在目標檢視view中的rect

- (cgrect)convertrect:(cgrect)recttoview

:(uiview

*)view;  

// 將rect從view中轉換到當前檢視中,返回在當前檢視中的rect

- (cgrect)convertrect:(cgrect)rectfromview

:(uiview

*)view;   例

把uitableviewcell

中的subview(btn)

的frame轉換到

controllera中

[objc]view plain

copy

// controllera 中有乙個uitableview, uitableview裡有多行uitableviecell,cell上放有乙個button

// 在controllera中實現:

cgrect rc = [cellconvertrect

:cell

.btn

.frame

toview

:self

.view

];  

或  cgrect rc = [self

.view

convertrect

:cell

.btn

.frame

fromview

:cell];  

// 此rc為btn在controllera中的rect

或當已知btn時:  

cgrect rc = [btn.superview

convertrect

:btn

.frame

toview

:self

.view

];  

或  cgrect rc = [self

.view

convertrect

:btn

.frame

fromview

:btn

.superview

];  

iOS開發筆記 UIView中的座標轉換

objc view plain copy 將畫素point由point所在檢視轉換到目標檢視view中,返回在目標檢視view中的畫素值 cgpoint convertpoint cgpoint pointtoview uiview view 將畫素point從view中轉換到當前檢視中,返回在當前...

iOS開發筆記

1.預設快取策略下 useprotocolcachepolicy 對於靜態資源的訪問,請求頭會自動帶上 if none match if modified since 快取方面,響應頭帶有 last modified etag 兩個字段 儘管charles抓包結果為304,但是 urlsession...

ios開發筆記 4

title ios開發筆記 4 date 2016 02 21 01 11 55 categories ios tags ios,筆記 一般此問題 都是由inte ce build與 中iboutlet的連線所引起的。可能是在 中對iboutlet的名稱進行了修改,導致inte ce build中的...