以下是使用可压缩UILabel的示例:
class VIEwController: UIVIEwController { var prevIEwingContext: UIVIEwControllerPrevIEwing? let label = UILabel(frame: CGRectMake(150,250,100,50)) overrIDe func vIEwDIDLoad() { super.vIEwDIDLoad() let background = UIImageVIEw(frame: vIEw.bounds) background.image = UIImage(named: "image.jpg") vIEw.addSubvIEw(background) label.backgroundcolor = UIcolor.whitecolor() label.text = "Press me!" label.textAlignment = .Center label.layer.cornerRadius = 20 label.clipsToBounds = true label.userInteractionEnabled = true vIEw.addSubvIEw(label) prevIEwingContext = registerForPrevIEwingWithDelegate(self,sourceVIEw: label) }}extension VIEwController: UIVIEwControllerPrevIEwingDelegate { func prevIEwingContext(prevIEwingContext: UIVIEwControllerPrevIEwing,vIEwControllerForLocation location: CGPoint) -> UIVIEwController? { prevIEwingContext.sourceRect = label.bounds return UIVIEwController() } func prevIEwingContext(prevIEwingContext: UIVIEwControllerPrevIEwing,commitVIEwController vIEwControllerToCommit: UIVIEwController) { showVIEwController(vIEwControllerToCommit,sender: self) }}总结
以上是内存溢出为你收集整理的ios – 如何围绕sourceRect的角落来寻找Peek和Pop 3D Touch?全部内容,希望文章能够帮你解决ios – 如何围绕sourceRect的角落来寻找Peek和Pop 3D Touch?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)