I have a UIView whose dimensions are (x: 16, y: 360, w: 369, h: 81) and I want to hide it with a UIAction by just sending it out of the screen. So I did UIView.animateWithDuration(0.2, animations: {self.View.frame = CGRectMake(x: -410, y: 360, 369, 81)})
, the ideal animation would be to have it slide out along the y-axis, however what I am getting now is the view going down and left (instead of just left). I'm kinda confused since I kept the 'y' the same in animation.
您正在移动视图控制器的视图,而不是要移动的视图(请注意self.view ...):
self.View.frame = CGRectMake(x: -410, y: 360, 369, 81)
我想我找到了问题,因为我将视图嵌入导航控制器中,标题可能与我的坐标拧在一起,所以我改用frame.origin.x
和frame.origin.y
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.