Swift

swift 九宫格

2020-08-03  本文已影响0人  江河_ios
       func showMessageView () {
         for  i in 0..<6 { 
        let Width = 80
        let height = 70
        let xa = 20 //x 初始值
        let ya = 30 //y 初始值
        
        let xz = 10 //横向间隔
        let yz = 15 //纵向间隔
        
        
        let X = xa+(xz + Width)*(i%4)
        
        let Y = ya+(yz+height)*(i/4)
        
     
        let frame = CGRect.init(x:X, y: Y , width: Width, height: height)
           
        let colorView = UIView.init(frame: frame)
        
        colorView.backgroundColor=UIColor.orange
        self.headerImage.addSubview(colorView)
           
       }
       
   }
上一篇 下一篇

猜你喜欢

热点阅读