Skip to content

Commit

Permalink
add centerHorizontallyInRect: helper
Browse files Browse the repository at this point in the history
  • Loading branch information
ettore committed Sep 30, 2013
1 parent e16bb0e commit bff45eb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
19 changes: 13 additions & 6 deletions categories/CLCGUIViewCategory.h
Expand Up @@ -28,22 +28,29 @@

@interface UIView (Candygirl)

/** Moves the X position of the view to the center of its superview. */
/*! Moves the X position of the view to the center of its superview. */
-(void)centerHorizontally;

/**
/*!
* Moves the X position of the view to the center of its superview, plus an
* additional offset. */
* additional offset.
*/
-(void)centerHorizontallyWithOffset:(CGFloat)offset;

/** Moves the Y position of the view to the center of its superview. */
/*! Moves the Y position of the view to the center of its superview. */
-(void)centerVertically;

/**
/*!
* Moves the Y position of the view to the center of its superview, plus an
* additional offset. */
* additional offset.
*/
-(void)centerVerticallyWithOffset:(CGFloat)offset;

/*!
* Centers this view in the given rect.
*/
-(void)centerHorizontallyInRect:(CGRect)rect;

-(void)resizeHeightForText:(NSString*)txt font:(UIFont*)font;
-(UIView*)findFirstResponder;

Expand Down
7 changes: 7 additions & 0 deletions categories/CLCGUIViewCategory.m
Expand Up @@ -66,6 +66,13 @@ -(void)centerHorizontallyWithOffset:(CGFloat)offset
}


-(void)centerHorizontallyInRect:(CGRect)rect
{
CGFloat x = (rect.size.width - [self w])/2;
[self setX:(rect.origin.x + x)];
}


-(void)resizeHeightForText:(NSString*)txt font:(UIFont*)font
{
CGSize sz;
Expand Down

0 comments on commit bff45eb

Please sign in to comment.