我需要在按钮周围显示一条短信。
在我看来,控制器有:
class myViewController: UIViewController {
@IBOutlet var backButton: UIButton!
@IBOutlet var myTitle: UITextView!
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
let exclusionPath:UIBezierPath = UIBezierPath(rect: backButton.frame)
myText.textContainer.exclusionPaths=[exclusionPath]
}
override func viewDidLoad() {
super.viewDidLoad()
myTitle.text="Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu"
}
}我进了模拟器

预期结果:

怎么了?
发布于 2014-12-15 20:53:18
exclusionPaths的文档将其描述为:An array of UIBezierPath objects representing the exclusion paths inside the receiver's bounding rectangle. Default value: nil.
您正在使用另一个视图的frame设置此属性,该属性使用不同的坐标系。记录这些属性的值(标签的frame和bounds,按钮的frame ),看看这些值是如何关联的,以及如何从一个转换到另一个。
相关文件:视图坐标系之间的转换
https://stackoverflow.com/questions/27492697
复制相似问题