Skip to content

quentinhayot/UIView-Rounded

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UIView+Rounded

Build Status
An UIView category for rounded views !
Create rounded or circular views that will keep their look upon resizing.

Installation

With CocoaPods

Add this to your Podfile:

pod 'UIView-Rounded'

Run a pod install and import the header where you need it:

#import <UIView+Rounded.h>

Manually

Drop UIView+Rounded.h and .m in your project, then

#import "UIView+Rounded.h"

Usage

You can use this category in two ways:

Create a rounded view with a custom border radius

UIView *myRoundedView = [[UIView alloc] init];  
[myRoundedView roundWithCornerRadius:0.5f andBorderWidth:2.0f andBorderColor:[UIColor whiteColor]];

Create a perfect circle view

UIView *myRoundedView = [[UIView alloc] init]; 
[myRoundView circleWithBorderWidth:2.0f andBorderColor:[UIColor whiteColor]];  
// If the view doesn't have a 1:1 ratio, the result will not look good.

// You are responsible to create and remove the following observer
// if you want the circle view to stay a circle on resizing
[myRoundView addObserver:myRoundView forKeyPath:@"bounds" options:0 context:nil];
[myRoundView removeObserver:myRoundView forKeyPath:@"bounds"];

About

An UIView category for rounded views !

Resources

License

Stars

Watchers

Forks

Packages

No packages published