6
A
回答
30
您需要更改UIImageView
的CGFrame像這樣 -
[imageView setFrame:CGRectMake(100, 100, imageView.frame.size.width, imageView.frame.size.height)];
這改變了uiimageview
poistion到(100, 100)
同時保持高度和寬度相同。請注意,您可以使用上述代碼不僅更改(x,y)
的位置,還更改視圖的大小。使用下面的代碼,你可以製作動畫太:)
如果你想動畫的位置變化 -
[UIView animateWithDuration:0.35
delay:0.0
options: UIViewAnimationCurveEaseOut
animations:^{
[imageView setFrame:CGRectMake(100, 100, imageView.frame.size.width, imageView.frame.size.height)];
}
completion:^(BOOL finished){
NSLog(@"Done!");
}];
0
self.psView.frame = CGRectMake(self.wvView.frame.origin.x, self.wvView.frame.origin.y, self.psView.frame.size.width, self.psView.frame.size.height);
+3
歡迎來到Stack Overflow!儘管這段代碼可以解決這個問題,但[包括一個解釋](// meta.stackexchange.com/questions/114762/explaining-entirely-code-based-answers)確實有助於提高您的帖子的質量。請記住,您將來會爲讀者回答問題,而這些人可能不知道您的代碼建議的原因。也請儘量不要使用解釋性註釋來擠佔代碼,因爲這會降低代碼和解釋的可讀性! – FrankerZ
相關問題
- 1. 如何更改UIImageView的角位置?
- 2. 改變位置的UIImageView通過選擇
- 3. 更改的位置,$位置
- 4. 根據設備的大小更改UIImageView的位置
- 5. 以編程方式更改UIImageview的位置iPhone
- 6. 在OS 3.0中更改UITableViewCell中左側UIImageView的位置
- 7. 位置更改的Android位置更新
- 8. UIImageView的Z位置與UIScrollView的位置
- 9. UIImageView無法以編程方式更改位置
- 10. 更改位置
- 11. 檢查UIImageView的位置
- 12. 在UIImageView上的位置
- 13. 我是否需要在更改UIImageView的位置後更新約束條件
- 14. 更新UIImageView圖像文件時,其他UIImageView的位置被重置爲中心
- 15. 更改iAd的位置和位置
- 16. 更改php.ini位置
- 17. 更改MouseEventArgs位置
- 18. 更改位置UITouch
- 19. 更改node_modules位置
- 20. 更改IsolatedStorage位置
- 21. UIButton更改位置
- 22. SVN位置更改
- 23. 更改UIImageView的寬度
- 24. 更改UIImageView的大小
- 25. 無法更改的UIImageView
- 26. 更改框架的UIImageView
- 27. 僅更改UIImageView的高度
- 28. UIImageView的大小更改
- 29. 更改位置設置
- 30. 更改imageview的位置
當我嘗試你的代碼(動畫版),我得到這個錯誤 發送'int'用於CGFrameMake行的不兼容類型'CGRect'(又名'struct CGRect')的參數。你知道也許是爲什麼? – bla0009
對不起'CGRectMake'而不是'CGFrameMake'。錯字!更新了上面的代碼...再試一次。 –
這是完美的。你只會缺少一個支架。我現在將其添加...投票完美答案! – bla0009