以编程方式向 UIButton 标签添加阴影

编程入门 行业动态 更新时间:2024-10-26 16:28:03
本文介绍了以编程方式向 UIButton 标签添加阴影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

I'm trying to add a 1px black drop shadow to a button label with no luck. I've tried this:self.setTitleShadowOffset = CGSizeMake(0, -1); but I get:

Request for member 'setTitleShadowOffset' in something not a structure or union

Any suggestions would be fantastic thanks!

解决方案

The other answers do not properly set the shadow color (I suspect they didn't notice because they were trying to set the shadow color to what it is by default, black.)

This code worked for me to add a white shadow to the text of my button:

myButton.titleLabel.shadowOffset = CGSizeMake(0, 1); [myButton setTitleShadowColor:[UIColor whiteColor] forState:UIControlStateNormal];

更多推荐

以编程方式向 UIButton 标签添加阴影

本文发布于:2023-11-12 18:42:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1582240.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:阴影   标签   方式   UIButton

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!