Round Icon Badge using CALayer and CATextLayer On UIBUtton

时间:2018-02-03 08:00:33

标签: ios swift ipad

[![enter image description here][1]][1]Can any one share their code relating to show round Badge number icon on UIButton on Top right Corner Using CALayer And CATextLayer and Add to UIButton

Thanks In advance

1 个答案:

答案 0 :(得分:-1)

For your badge, you can use only label for showing the badge on button specially.

let label = UILabel()
label.clipsToBounds = true
label.layer.cornerRadius = label.font.pointSize * 1.2 / 2
label.backgroundColor = UIColor.grayColor()
label.textColor = UIColor.whiteColor()
label.text = " Some Text "; // note spaces before and after text

And For reusability, you can create the category or extension for this code.