iOS UITextField 内边距

2022-11-11  本文已影响0人  我会回来的

override func textRect(forBounds bounds: CGRect) -> CGRect {

        // top left

        CGRect(x: bounds.minX, y: bounds.minY, width: bounds.width / 2, height: bounds.height / 2)

    }

    override func placeholderRect(forBounds bounds: CGRect) -> CGRect {

        // top right

        CGRect(x: bounds.midX, y: bounds.minY, width: bounds.width / 2, height: bounds.height / 2)

    }

    override func borderRect(forBounds bounds: CGRect) -> CGRect {

        // bottom left

        CGRect(x: bounds.minX, y: bounds.midY, width: bounds.width / 2, height: bounds.height / 2)

    }

    override func editingRect(forBounds bounds: CGRect) -> CGRect {

        // bottom right

        CGRect(x: bounds.midX, y: bounds.midY, width: bounds.width / 2, height: bounds.height / 2)

    }

上一篇下一篇

猜你喜欢

热点阅读