//
// UIView+Extension.swift
// WBDemo
//
// Created by zhaodajun on 16/8/10.
// Copyright © 2016年 zhaodajun. All rights reserved.
//
import UIKit
extension UIView {
public var x: CGFloat{
get{
return self.frame.origin.x
}
set{
var r = self.frame
r.origin.x = newValue
self.frame = r
}
}
public var y: CGFloat{
get{
return self.frame.origin.y
}
set{
var r = self.frame
r.origin.y = newValue
self.frame = r
}
}
public var rightX: CGFloat{
get{
return self.x + self.width
}
set{
var r = self.frame
r.origin.x = newValue - frame.size.width
self.frame = r
}
}
public var bottomY: CGFloat{
get{
return self.y + self.height
}
set{
var r = self.frame
r.origin.y = newValue - frame.size.height
self.frame = r
}
}
public var centerX : CGFloat{
get{
return self.center.x
}
set{
self.center = CGPoint(x: newValue, y: self.center.y)
}
}
public var centerY : CGFloat{
get{
return self.center.y
}
set{
self.center = CGPoint(x: self.center.x, y: newValue)
}
}
public var width: CGFloat{
get{
return self.frame.size.width
}
set{
var r = self.frame
r.size.width = newValue
self.frame = r
}
}
public var height: CGFloat{
get{
return self.frame.size.height
}
set{
var r = self.frame
r.size.height = newValue
self.frame = r
}
}
public var origin: CGPoint{
get{
return self.frame.origin
}
set{
self.x = newValue.x
self.y = newValue.y
}
}
public var size: CGSize{
get{
return self.frame.size
}
set{
self.width = newValue.width
self.height = newValue.height
}
}
}
网友评论