如何才能使我的UIView始终与屏幕右侧齐平而没有自动布局?

时间:2016-07-27 22:34:30

标签: swift

我试图让我的UIView始终保持在屏幕的右侧:

let yPosition: CGFloat = UIApplication.sharedApplication().statusBarOrientation.isPortrait ? 54.0 : 38.0
self.customView = CustomView(frame: CGRectMake(0, yPosition, 255, 306.8))
self.view.addSubview(self.customView!)

1 个答案:

答案 0 :(得分:1)

试试这个:

let yPosition: CGFloat = UIApplication.sharedApplication().statusBarOrientation.isPortrait ? 54.0 : 38.0
self.customView = CustomView()
self.customView!.frame.size = CGSize(width: 255, height: 306.8)
self.customView!.frame.origin = CGPointMake(self.view.frame.size.width - self.customView!.frame.size.width, yPosition)
self.view.addSubview(self.customView!)