简体   繁体   中英

Most memory efficient way to make a bulging/rounded button in iOS?

I'd like to make a button that looks like this:

圆形凸起按钮

What's the most memory efficient way to do this shape (I'm not concerned with the icon/text inside)? The way I see it I can either load it as a png button item or draw it as a UIBezierPath of some kind. In the latter case, I'm confused about how to get the effect I have. I would think I join a bunch of arcs, but is there a way to get those corners just right without a lot of experimentation? Also, which is more performance, a png or drawing? Also is there another way to do this that I'm missing?

I usually approach this by setting the layer.cornerRadius of the button, it works great and is easy to implement with various background icons. You would achieve a similar effect as in the screenshot by setting the radius to 2/3rds of the button height if it is squared.

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