2017-08-11 70 views
0

大致我現在使用的。但是,在不同設備上使用時,限制可能太小。我怎樣才能將這個設置爲基於屏幕大小以便通用?用UIPanGestureRecognizer轉換到屏幕邊緣。

-(void)move:(UIPanGestureRecognizer *)pan { 
CGPoint translated =[panlocationInView:pan.view.superview]; 
if (translated.x >= 64 && translated.x <= 328) { 
pan.view.center = CGPointMake(translated.x, pan.view.center.y); 
[pan setTranslation:CGPointMake(0, 0) inView:pan.view.superview]; 
} 
} 

回答

0

我認爲你正在尋找的屬性是view.frame(認爲可能是在viewControllers查看)

具體來說,你想:

view.frame.minX + 64 
view.frame.maxX - 64 

定義的範圍。