Posted By

TheRabbitFlash on 03/30/15


Tagged

as3 swift


Versions (?)

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


 / Published in: Other
 

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;

  1. // Save as UIViewExtension
  2.  
  3. import UIKit
  4.  
  5. extension UIView {
  6. var x: CGFloat {
  7. get {
  8. return self.frame.origin.x;
  9. }
  10. set {
  11. var rect : CGRect = self.frame;
  12. rect.origin.x = newValue;
  13. self.frame = rect;
  14. }
  15. }
  16.  
  17. var y: CGFloat {
  18. get {
  19. return self.frame.origin.y;
  20. }
  21. set {
  22. var rect : CGRect = self.frame;
  23. rect.origin.y = newValue;
  24. self.frame = rect;
  25. }
  26. }
  27.  
  28. var width: CGFloat {
  29. get {
  30. return self.frame.width;
  31. }
  32. set {
  33. var rect : CGRect = self.frame;
  34. rect.size.width = newValue;
  35. self.frame = rect;
  36. }
  37. }
  38.  
  39. var height: CGFloat {
  40. get {
  41. return self.frame.height;
  42. }
  43. set {
  44. var rect : CGRect = self.frame;
  45. rect.size.height = newValue;
  46. self.frame = rect;
  47. }
  48. }
  49. }

Report this snippet  

You need to login to post a comment.