Tiled Background Image: Can I do that easily with UIImageView?

前端 未结 7 1090
甜味超标
甜味超标 2020-12-07 13:05

I have a fullscreen background image that is tiled, i.e. it has to be reproduced a few times horizontally and vertically in order to make a big one. Like in the browsers on

7条回答
  •  遥遥无期
    2020-12-07 13:51

    Swift version of Daniel T's solution. You still need to set the keyPath value in IB. Of course you could be more careful unwrapping the Optional UIImage.

    extension UIView {
        var colorPattern:String {
            get {
                return ""  // Not useful here.
            }
            set {
                self.backgroundColor = UIColor(patternImage: UIImage(named:newValue)!)
            }
        }
    }
    

提交回复
热议问题