两个类拓展
UIView的
//
// UIView+LM.h
// 设置 frame
//
// Created by laimin on 16/8/21.
// Copyright © 2016年 laimin. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIView (LM)
@property (assign,nonatomic) CGFloat X;
@property (assign,nonatomic) CGFloat Y;
@property (assign,nonatomic) CGFloat W;
@property (assign,nonatomic) CGFloat H;
@property (assign,nonatomic,readonly) CGFloat MaxX;
@property (assign,nonatomic,readonly) CGFloat MaxY;
//获取最大 x 值
-(CGFloat)MaxX;
//获取最大 y 值
-(CGFloat)MaxY;
@end
//
// UIView+LM.m
// 设置 frame
//
// Created by laimin on 16/8/21.
// Copyright © 2016年 laimin. All rights reserved.
//
#import "UIView+LM.h"
@implementation UIView (LM)
-(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)setW:(CGFloat)W
{
CGRect frame = self.frame;
frame.size.width = W;
self.frame = frame;
}
-(CGFloat)W
{
return self.frame.size.width;
}
-(void)setH:(CGFloat)H
{
CGRect frame = self.frame;
frame.size.height = H;
self.frame = frame;
}
-(CGFloat)H
{
return self.frame.size.height;
}
-(CGFloat)MaxX
{
return CGRectGetMaxX(self.frame);
}
-(CGFloat)MaxY
{
return CGRectGetMaxY(self.frame);
}
@end
CALayer的
//
// CALayer+LMXYWH.h
// 02-图层树
//
// Created by laimin on 17/4/16.
// Copyright © 2017年 laimin. All rights reserved.
//
#import <QuartzCore/QuartzCore.h>
@interface CALayer (LMXYWH)
@property (assign,nonatomic) CGFloat X;
@property (assign,nonatomic) CGFloat Y;
@property (assign,nonatomic) CGFloat W;
@property (assign,nonatomic) CGFloat H;
@property (assign,nonatomic,readonly) CGFloat MaxX;
@property (assign,nonatomic,readonly) CGFloat MaxY;
//获取最大 x 值
-(CGFloat)MaxX;
//获取最大 y 值
-(CGFloat)MaxY;
@end
//
// CALayer+LMXYWH.m
// 02-图层树
//
// Created by laimin on 17/4/16.
// Copyright © 2017年 laimin. All rights reserved.
//
#import "CALayer+LMXYWH.h"
@implementation CALayer (LMXYWH)
-(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)setW:(CGFloat)W
{
CGRect frame = self.frame;
frame.size.width = W;
self.frame = frame;
}
-(CGFloat)W
{
return self.frame.size.width;
}
-(void)setH:(CGFloat)H
{
CGRect frame = self.frame;
frame.size.height = H;
self.frame = frame;
}
-(CGFloat)H
{
return self.frame.size.height;
}
-(CGFloat)MaxX
{
return CGRectGetMaxX(self.frame);
}
-(CGFloat)MaxY
{
return CGRectGetMaxY(self.frame);
}
@end