Home > Enterprise >  Best way to create Custom (Octagonal) UIButton in Swift
Best way to create Custom (Octagonal) UIButton in Swift

Time:12-31

I am about to customize all of my UIButtons by subclassing them into a special UIButton class and I want to have the "look and feel" like below octagonal or some hexagonal buttons. What would be the best way to create such shape UI buttons? So far, I only know how to create rectangle, circular and rounded-edge buttons, and I could not find SO answers or cocoapods for below "look and feel".

  1. Is it possible to create a custom class of such UIButton programmatically?

  2. Or do I need to import an image onto a button to realize below "look and feel"?

  3. Also, could there be any possibility be that App Store does not allow such custom shape buttons?

enter image description here

CodePudding user response:

  1. Yes you can use UIBezierPath to create arbitrary shapes for a variety of UIKit components that includes UIButton. See tutorial enter image description here

  • Related