This UIButton subclass replicate single line border button see in iOS 7 App Store.
SWFrameButton is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "SWFrameButton"
You may also quickly try the SWFrameButton example project with
pod try SWFrameButton
Requires iOS 7.0+ and ARC.
SWFrameButton design to use tintColor
to determine its color, so try to avoid set text color by setTitleColor:forState:
it won't break your button, but may raise inconsistent highlighted/selected color state. Text Color
property in Interface Builder will be ignore for this reason, use Tint
property in view section instead.
Basic usage
SWFrameButton *button = [[SWFrameButton alloc] init];
[button setTitle:@"Green Tint Button" forState:UIControlStateNormal];
[button sizeToFit];
button.tintColor = [UIColor greenColor];
If you use Interface Builder, add a UIBUtton to your interface and set Class to SWFrameButton
.
You can use customize SWFrameButton using UIAppearance
[[SWFrameButton appearance] setTintColor:[UIColor orangeColor]];
[[SWFrameButton appearance] setBorderWidth:1];
[[SWFrameButton appearance] setCornerRadius:10];
or set individual button style via property
SWFrameButton *button = [[SWFrameButton alloc] init];
button.tintColor = [UIColor orangeColor];
button.borderWidth = 1;
button.corderRadius = 10;
Sarun Wongpatcharapakorn (@sarunw)
SWFrameButton is available under the MIT license. See the LICENSE file for more info.