Return to Snippet

Revision: 68981
at March 30, 2015 05:24 by TheRabbitFlash


Initial Code
// Save as UIViewExtension

import UIKit

extension UIView {
    var x: CGFloat {
        get {
            return self.frame.origin.x;
        }
        set {
            var rect : CGRect = self.frame;
            rect.origin.x = newValue;
            self.frame = rect;
        }
    }
    
    var y: CGFloat {
        get {
            return self.frame.origin.y;
        }
        set {
            var rect : CGRect = self.frame;
            rect.origin.y = newValue;
            self.frame = rect;
        }
    }
    
    var width: CGFloat {
        get {
            return self.frame.width;
        }
        set {
            var rect : CGRect = self.frame;
            rect.size.width = newValue;
            self.frame = rect;
        }
    }
    
    var height: CGFloat {
        get {
            return self.frame.height;
        }
        set {
            var rect : CGRect = self.frame;
            rect.size.height = newValue;
            self.frame = rect;
        }
    }
}

Initial URL

                                

Initial Description
UIView Extension that allow to set/get x,y,width,height in ActionScript 3.0 

myView.x  =30;
myView2.x = myView.x;

myTextField.x = 30;

Initial Title
UIView Extension that allow to set/get x,y,width,height in ActionScript 3.0

Initial Tags

                                

Initial Language
Other