弹出Pop样式,上,下,左,右四个方向

扩充了以前的Popover只有上,下两种方向
首先还是附上demo效果:

popOver.gif

github地址:https://github.com/shine93/XXPopover

问题:pop出来可以看到上面的字有显示不到的地方,其实显示字的是label。设置label的inset就可以了。

//自定义一个带有textPaddings的label
class LabelWithPaddings: UILabel {
    var textPaddings: UIEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)

    override func drawText(in rect: CGRect) {
        super.drawText(in: UIEdgeInsetsInsetRect(rect, textPaddings))
    }
}
//自定义label的textPaddings
let label = LabelWithPaddings()
label.textPaddings = UIEdgeInsets(top: 4, left: 12, bottom: 4, right: 12)

引入自己项目使用的话直接拖入Popover.swift文件。
内容再补充。

你可能感兴趣的:(弹出Pop样式,上,下,左,右四个方向)