我有这个布局。 1,2,3和4代表UIButton。红色是UIImageView。使用Swift创建这些按钮的最佳方法是什么。
我考虑过使用具有透明信息的png图像。它会创建宽度和高度的UIButton。见图2.
答案 0 :(得分:0)
我认为最好的(非耗时)选项是使用OBShapedButton库,它通过创建图像蒙板来解决我的问题。
Objective-C版本: https://github.com/ole/OBShapedButton/tree/master/OBShapedButton
Swift版本: https://gist.github.com/clmntcrl/8e4cab3ed7d1e7da47e7