Skip to content

Commit

Permalink
Adding bounds properties to UIView category.
Browse files Browse the repository at this point in the history
  • Loading branch information
kreeger committed Jun 5, 2013
1 parent 76ab11d commit 2327a50
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 2 deletions.
4 changes: 2 additions & 2 deletions BDKGeometry.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'BDKGeometry'
s.version = '1.4.0'
s.version = '1.4.1'
s.platform = :ios
s.summary = "A set of helper functions I've been using in various XCode projects, abstracted for great good."
s.homepage = 'http://github.com/kreeger/BDKGeometry'
Expand All @@ -17,7 +17,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
LICENSE
}
s.author = { 'Ben Kreeger' => 'ben@kree.gr' }
s.source = { :git => 'https://github.com/kreeger/BDKGeometry.git', :tag => 'v1.4.0' }
s.source = { :git => 'https://github.com/kreeger/BDKGeometry.git', :tag => 'v1.4.1' }
s.ios.deployment_target = '5.0'
s.source_files = ['BDKGeometry.{h,m}', 'UIView+BDKGeometry.{h,m}']
s.requires_arc = true
Expand Down
6 changes: 6 additions & 0 deletions UIView+BDKGeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ typedef enum {
@property (nonatomic) CGSize frameSize;
@property (nonatomic) CGFloat frameWidth;
@property (nonatomic) CGFloat frameHeight;
@property (nonatomic) CGPoint boundsOrigin;
@property (nonatomic) CGFloat boundsXOrigin;
@property (nonatomic) CGFloat boundsYOrigin;
@property (nonatomic) CGSize boundsSize;
@property (nonatomic) CGFloat boundsWidth;
@property (nonatomic) CGFloat boundsHeight;

/** Origin modification helper.
* @param origin the origin to use.
Expand Down
53 changes: 53 additions & 0 deletions UIView+BDKGeometry.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
@implementation UIView (BDKGeometry)

@dynamic frameOrigin, frameXOrigin, frameYOrigin, frameSize, frameWidth, frameHeight;
@dynamic boundsOrigin, boundsXOrigin, boundsYOrigin, boundsSize, boundsWidth, boundsHeight;

#pragma mark - Frame methods

- (void)setFrameOrigin:(CGPoint)frameOrigin {
self.frame = CGRectSetOrigin(self.frame, frameOrigin);
Expand Down Expand Up @@ -53,6 +56,56 @@ - (CGFloat)frameHeight {
return self.frame.size.height;
}

#pragma mark - Bounds methods

- (void)setBoundsOrigin:(CGPoint)boundsOrigin {
self.bounds = CGRectSetOrigin(self.bounds, boundsOrigin);
}

- (CGPoint)boundsOrigin {
return self.bounds.origin;
}

- (void)setBoundsXOrigin:(CGFloat)boundsXOrigin {
self.bounds = CGRectSetXOrigin(self.bounds, boundsXOrigin);
}

- (CGFloat)boundsXOrigin {
return self.bounds.origin.x;
}

- (void)setBoundsYOrigin:(CGFloat)boundsYOrigin {
self.bounds = CGRectSetYOrigin(self.bounds, boundsYOrigin);
}

- (CGFloat)boundsYOrigin {
return self.bounds.origin.y;
}

- (void)setBoundsSize:(CGSize)boundsSize {
self.bounds = CGRectSetSize(self.bounds, boundsSize);
}

- (CGSize)boundsSize {
return self.bounds.size;
}

- (void)setBoundsWidth:(CGFloat)boundsWidth {
self.bounds = CGRectSetWidth(self.bounds, boundsWidth);
}

- (CGFloat)boundsWidth {
return self.bounds.size.width;
}

- (void)setBoundsHeight:(CGFloat)boundsHeight {
self.bounds = CGRectSetHeight(self.bounds, boundsHeight);
}

- (CGFloat)boundsHeight {
return self.bounds.size.height;
}

- (void)positionViewBelowView:(UIView *)view {
[self positionViewBelowView:view padding:0];
}
Expand Down

0 comments on commit 2327a50

Please sign in to comment.