如何使用UIView
使CGRectMake
水平居中并距 View Controller 顶部30px?
var draggableView: DraggableView = DraggableView(frame:CGRectMake(0 , 30, 260, 260))
draggableView.center = center
最佳答案
尝试:
let size = 260
let screenWidth = self.view.frame.size.width
let frame = CGRectMake((screenWidth / 2) - (size / 2), 30, size, size)
let draggableView = DraggableView(frame: frame)
self.view.addSubview(draggableView)
关于ios - 如何将UIView水平居中?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28614969/