0

Anyone have idea how make button on Xcode like on picture(Right side on image)? I want put icon image and title on view container for better alignment like on left side image. But I dont know how get @IBAction property, if it's not be a button.

Image size of my button should be 44x44(green rectangle).

Label(system, 14 pt) should be on frame with size 66x20(if text greater, text should be truncated).

I've tried add to storyboard button and then set background image, title and adjust insets on Size Inspector. Nothing succeeded.

Thanks for help.

enter image description here

Mahendra
  • 8,448
  • 3
  • 33
  • 56
Bandyliuk
  • 489
  • 4
  • 13

2 Answers2

-1

You use MTCompoundButton lib.

Link of MTCompoundButton :- https://github.com/mta452/UIView-TouchHighlighting

Now you get UIView and inside of it take UIImage and UILabel.

Then set MTCompoundButton in UIView.

Chirag Kothiya
  • 955
  • 5
  • 12
  • 28
-2

My advice would be to simply use a UIImage and then have a UIButton above that image with no text inside of it. All of this can be done within the storyboard. Just make sure that the button is the same size of the image, is transparent, and does not have any text within it. You can then link the button to your ViewController and use the @IBAction function.

Jayesh Thanki
  • 2,037
  • 2
  • 23
  • 32
Patrick Haertel
  • 309
  • 4
  • 15