iPhone UILabel text soft shadow

前端 未结 15 971
时光取名叫无心
时光取名叫无心 2020-12-07 09:31

I know soft shadows are not supported by the UILabel out of the box, on the iPhone. So what would be the best way to implement my own one?

EDIT:

15条回答
  •  时光说笑
    2020-12-07 10:24

    Additionally to IIDan's answer: For some purposes it is necessary to set

    label.layer.shouldRasterize = YES
    

    I think this is due to the blend mode that is used to render the shadow. For example I had a dark background and white text on it and wanted to "highlight" the text using a black shadowy glow. It wasn't working until I set this property.

提交回复
热议问题