#import "UIView+JING.h"
@property (nonatomic, assign) CGFloat originX;
@property (nonatomic, assign) CGFloat originY;
@property (nonatomic, assign) CGFloat width;
@property (nonatomic, assign) CGFloat height;
- (UIViewController *)superViewController;
//改版view的orx
- (void)beforeViewOrY:(UIView *)view WithInterval:(float)interval;
//改变view的ory
- (void)beforeViewOrX:(UIView *)view WithInterval:(float)interval;
//获取绝对坐标(相对于屏幕的坐标)
- (CGRect)convertRectFrame;
#import "UIView+JING.m"
//获取view所在的con
- (UIViewController *)superViewController{ //
for (UIView* next = [self superview]; next; next = next.superview) {
UIResponder *nextResponder = [next nextResponder];
if ([nextResponder isKindOfClass:[UIViewController class]]) {
return (UIViewController *)nextResponder;
}
}
return nil;
}
//改变view的orx
- (void)beforeViewOrY:(UIView *)view WithInterval:(float)interval{
self.originY = view.originY-self.height-interval;
}
//改变view的ory
- (void)beforeViewOrX:(UIView *)view WithInterval:(float)interval{
self.originX = view.originX-self.width-interval;
}
- (void)setOriginX:(CGFloat)originX
{
CGRect frame = self.frame;
frame.origin.x = originX;
self.frame = frame;
}
- (CGFloat)originX
{
return self.frame.origin.x;
}
- (void)setOriginY:(CGFloat)originY
{
CGRect frame = self.frame;
frame.origin.y = originY;
self.frame = frame;
}
- (CGFloat)originY
{
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;
}
//获取绝对坐标(相对于屏幕的坐标)
- (CGRect)convertRectFrame{
return [self convertRect:self.bounds toView:self.window];
}