You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
2.3 KiB

//
// UIView+convenience.m
//
// Created by Tjeerd in 't Veen on 12/1/11.
// Copyright (c) 2011 Vurig Media. All rights reserved.
//
#import "UIView+convenience.h"
@implementation UIView (convenience)
-(BOOL) containsSubView:(UIView *)subView
{
for (UIView *view in [self subviews]) {
if ([view isEqual:subView]) {
return YES;
}
}
return NO;
}
-(BOOL) containsSubViewOfClassType:(Class)class {
for (UIView *view in [self subviews]) {
if ([view isMemberOfClass:class]) {
return YES;
}
}
return NO;
}
- (CGPoint)frameOrigin {
return self.frame.origin;
}
- (void)setFrameOrigin:(CGPoint)newOrigin {
self.frame = CGRectMake(newOrigin.x, newOrigin.y, self.frame.size.width, self.frame.size.height);
}
- (CGSize)frameSize {
return self.frame.size;
}
- (void)setFrameSize:(CGSize)newSize {
self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y,
newSize.width, newSize.height);
}
- (CGFloat)frameX {
return self.frame.origin.x;
}
- (void)setFrameX:(CGFloat)newX {
self.frame = CGRectMake(newX, self.frame.origin.y,
self.frame.size.width, self.frame.size.height);
}
- (CGFloat)frameY {
return self.frame.origin.y;
}
- (void)setFrameY:(CGFloat)newY {
self.frame = CGRectMake(self.frame.origin.x, newY,
self.frame.size.width, self.frame.size.height);
}
- (CGFloat)frameRight {
return self.frame.origin.x + self.frame.size.width;
}
- (void)setFrameRight:(CGFloat)newRight {
self.frame = CGRectMake(newRight - self.frame.size.width, self.frame.origin.y,
self.frame.size.width, self.frame.size.height);
}
- (CGFloat)frameBottom {
return self.frame.origin.y + self.frame.size.height;
}
- (void)setFrameBottom:(CGFloat)newBottom {
self.frame = CGRectMake(self.frame.origin.x, newBottom - self.frame.size.height,
self.frame.size.width, self.frame.size.height);
}
- (CGFloat)frameWidth {
return self.frame.size.width;
}
- (void)setFrameWidth:(CGFloat)newWidth {
self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y,
newWidth, self.frame.size.height);
}
- (CGFloat)frameHeight {
return self.frame.size.height;
}
- (void)setFrameHeight:(CGFloat)newHeight {
self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y,
self.frame.size.width, newHeight);
}
@end