[ObjC] UIButton with rounded corners

APRoundedButton is a simple XIB/Storyboard extension to make rounded custom buttons, without writing one line of code!

Requirements

  • ARC
  • iOS 7+
  • Xcode 5

How to use

Copy in your project the files:

[code lang=”cpp” autolinks=”false” collapse=”false” firstline=”1″ gutter=”true” htmlscript=”false” light=”false” padlinenumbers=”false” smarttabs=”true” tabsize=”4″ toolbar=”false”]APRoundedButton.h
APRoundedButton.m[/code]

and add QuartzCore framework.

ss-a

Next, open your XIB or Storyboard, make a button, and select the 3rd tab.
Change UIButton default class with APRoundedButton.

Your buttons appear normally (squared), like this:
ss-b

Now, add a User-defined Runtime Attributes. In the same tab (class), for each custom button you want:
ss-c

add a style key path, of type Number with a value from 0 to 10.

That’s all.
Build and run. You should see something like this:

ss-d

No one line of code is needed!

Full project on github: https://github.com/elpsk/APRoundedButton

have fun.

Want Android version?
Look here!
http://www.albertopasca.it/whiletrue/2014/04/android-button-with-rounded-corners/

Want new version, using IBInspectable?
Look here:
http://www.albertopasca.it/whiletrue/2015/11/objc-uibutton-with-rounded-corners-ibinspectable/

ref:
albertopasca.it

Alberto Pasca