可以通过:
UIEdgeInsetsInsetRect
去调整一个frame的尺寸
代码:
let originRect = CGRectMake(0, 0, 200, 400) let demoView = UIView(frame: originRect) let shrinkedRect = UIEdgeInsetsInsetRect(originRect, UIEdgeInsetsMake(0, 30, 0, 100)) let expandedRect = UIEdgeInsetsInsetRect(originRect, UIEdgeInsetsMake(0, 0, 0, -300))
效果: