【问题标题】:Adding a inner border bottom to a subclass of UiView in swift4在swift4中为UiView的子类添加内边框底部
【发布时间】:2018-08-25 08:52:01
【问题描述】:

我想在 UIView 的一个子类(自定义)中添加一个内边框底部,我正在查看是否有 UIview 的扩展。提前致谢。

【问题讨论】:

    标签: uiview uikit swift4 ios11 xcode9


    【解决方案1】:
    extension UIView {
        func customBorder(){
            let borderWidth: CGFloat = 0.84
            self.frame = frame.insetBy(dx: -borderWidth, dy: -borderWidth)
            self.layer.borderColor = UIColor.white.cgColor
            self.layer.borderWidth = borderWidth
            self.clipsToBounds = true
        }
    }
    

    【讨论】:

    • CGRectInset 被 swift4 中的 CGRect.insetBy 方法替换。怎么办?
    • @kamalakshihegde 检查更新的答案。您还可以将目标 C 代码转换为 swift online.
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-20
    • 1970-01-01
    • 2022-12-01
    • 2016-02-13
    • 2013-06-25
    相关资源
    最近更新 更多