简体   繁体   中英

UIButton corner radius with background Image

I am trying to set up a custom UIButton which is rounded and has an image inside. I am able to get the rounded button but after configuring the button's corner radius, the image disappears.

I found this Stack Overflow question, but after trying the solutions mentioned there, the button is still not showing the image.

A screenshot is added below:

Any help will be appreciated.

在此处输入图像描述

Call super.layoutSubviews() inside the layoutSubviews()

or simply remove the layoutSubviews() function will do the trick:)

Seems like you are setting the backgroundColor same as the image color! So you cant see the image easily.

Try changing the image color by settings the tintColor of the button:

button.tintColor = .red

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM