An UIView category for rounded views !
Create rounded or circular views that will keep their look upon resizing.
Add this to your Podfile:
pod 'UIView-Rounded'
Run a pod install
and import the header where you need it:
#import <UIView+Rounded.h>
Drop UIView+Rounded.h and .m in your project, then
#import "UIView+Rounded.h"
You can use this category in two ways:
UIView *myRoundedView = [[UIView alloc] init];
[myRoundedView roundWithCornerRadius:0.5f andBorderWidth:2.0f andBorderColor:[UIColor whiteColor]];
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"];