[Objc] UIButton with rounded corners (IBInspectable)

APRoundedButton is a simple /Storyboard extension to make rounded custom buttons, without writing one line of code, now using IBInspectable.

What are IBInspectable?

IBInspectable properties provide new access to an old feature: .
Currently accessible from the identity inspector, these attributes have been available since before
Interface Builder was integrated into Xcode.

They provide a powerful mechanism for configuring any key-value coded property of an instance in a , XIB, or storyboard.

dochttps://developer.apple.com/library/ios/recipes/xcode_help-IB_objects_media/Chapters/CreatingaLiveViewofaCustomObject.html

How to use

Requirements

  • ARC
  • iOS 7+
  • Xcode 5

Copy in your project the files:

APRoundedButton.h
APRoundedButton.m

and add QuartzCore framework.

Steps:
  • Open your XIB or Storyboard
  • Draw a 
  • Change the default class to APRoundedButton
Available options:
  • Corner TOP LEFT
  • Corner TOP RIGTH
  • Corner BOTTOM LEFT
  • Corner BOTTOM RIGTH
  • Corner
  • BUTTON COLOR

You should see “Rounded Button” options.
…try to change and you see in realtime the preview of your corners!

ss

Build and run. That’s all!
No one line of code is needed!

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

have fun.


The old one article “UIButton with rounded corners” do the same thing but usingUser-defined Runtime Attributes.

ss-c

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

ref:
albertopasca.it