1 UIViewの分類

1671 ワード

UIViewの分類を設定すると自分で使いやすいです.
//UIView+Extension

import UIKit

//                 

extension UIView {
    
    var x:CGFloat {
        
        get {
            
            return self.frame.origin.x
        } set {
            
            self.frame.origin.x = newValue
        }
        
    }
    
    
    var y : CGFloat {
        
        get {
            return self.frame.origin.y
        } set {
            self.frame.origin.y = newValue
        }
        
    }
    
    
    
    var width : CGFloat {
        
        //     get set          
        
        get {
            return self.frame.size.width
        } set {
            self.frame.size.width = newValue
        }
        
        
    }
    
    var height : CGFloat {
        
        //     get set          
        
        get {
            return self.frame.size.height
        } set {
            self.frame.size.height = newValue
        }
        
        
    }
    
    
    //   size      size
    var size : CGSize {
        
        //     get set          
        
        get {
            return self.frame.size
        } set {
            self.frame.size = newValue
        }
        
        
    }
    
    
    //     x        X
    var centerX : CGFloat {
        
        //     get set          
        
        get {
            return self.center.x
        } set {
            self.center.x = newValue
        }
        
    }
    
    
    var centerY : CGFloat {
        
        //     get set          
        
        get {
            return self.center.y
        } set {
            self.center.y = newValue
        }
    }
    
}