美文网首页Swift
swift 九宫格

swift 九宫格

作者: 江河_ios | 来源:发表于2020-08-03 17:54 被阅读0次
       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)
           
       }
       
   }

相关文章

网友评论

    本文标题:swift 九宫格

    本文链接:https://www.haomeiwen.com/subject/dousrktx.html