123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- //
- // UIView+Frame.m
- // Source
- //
- // Created by MD101 on 16/1/25.
- // Copyright © 2016年 yaocheng. All rights reserved.
- //
- #import "UIView+Frame.h"
- @implementation UIView (Frame)
- - (void)setX:(CGFloat)x{
- CGRect frame = self.frame;
- frame.origin.x = x;
- self.frame = frame;
- }
- - (CGFloat)x{
- return self.frame.origin.x;
- }
- - (void)setY:(CGFloat)y{
- CGRect frame = self.frame;
- frame.origin.y = y;
- self.frame = frame;
- }
- - (CGFloat)y{
- return self.frame.origin.y;
- }
- - (void)setWidth:(CGFloat)width{
- CGRect frame = self.frame;
- frame.size.width = width;
- self.frame = frame;
- }
- - (CGFloat)width{
- return self.frame.size.width;
- }
- - (void)setHeight:(CGFloat)height{
- CGRect frame = self.frame;
- frame.size.height = height;
- self.frame = frame;
- }
- - (CGFloat)height{
- return self.frame.size.height;
- }
- - (void)setCenterX:(CGFloat)centerX{
- CGPoint point = self.center;
- point.x = centerX;
- self.center = point;
- }
- - (CGFloat)centerX{
- return self.center.x;
- }
- - (void)setCenterY:(CGFloat)centerY{
- CGPoint point = self.center;
- point.y = centerY;
- self.center = point;
- }
- - (CGFloat)centerY{
- return self.center.y;
- }
- - (void)setSize:(CGSize)size{
- CGRect frame = self.frame;
- frame.size = size;
- self.frame = frame;
- }
- - (CGSize)size{
- return self.frame.size;
- }
- - (CGFloat)right
- {
- return self.frame.origin.x + self.frame.size.width;
- }
- - (void)setRight:(CGFloat)right
- {
- CGRect frame = self.frame;
- frame.origin.x = right - self.frame.size.width;
- self.frame = frame;
- }
- - (CGFloat)bottom
- {
- return self.frame.origin.y + self.frame.size.height;
- }
- - (void)setBottom:(CGFloat)bottom
- {
- CGRect frame = self.frame;
- frame.origin.y = bottom - self.frame.size.height;
- self.frame = frame;
- }
- @end
|