iPhone UILabel 属性

发布于 2024-11-25 05:05:22 字数 97 浏览 1 评论 0原文

我正在尝试在 UILabel 上设置阴影。

我希望阴影的角度为 -90 度,距离为 1 像素,不透明度为 55%,大小为 0 像素。

以上如何实现?

I'm trying to set a shadow on my UILabel.

I'd like the shadow to be at a -90 degree angle, 1 px distance, 55% opacity and 0px size.

How above can this implemented ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爱*していゐ 2024-12-02 05:05:22

很确定 px 距离是由字体决定的,如果不是,我找不到方法来获取它。

UITextLabel *label = [[[UITextLabel alloc] init] autorelease];

//Shadow straight down
[label setShadowOffset:CGSizeMake(0,1)];

//55% opacity
[label setShadowColor:[[label shadowColor] colorWithAlphaComponent:.55]];

Pretty sure px distance is determined by font, if it isn't i cant find a way to get to it.

UITextLabel *label = [[[UITextLabel alloc] init] autorelease];

//Shadow straight down
[label setShadowOffset:CGSizeMake(0,1)];

//55% opacity
[label setShadowColor:[[label shadowColor] colorWithAlphaComponent:.55]];
本王不退位尔等都是臣 2024-12-02 05:05:22
UITextLabel *label = [[[UILabel alloc] init] autorelease];
label.shadowOffset = CGSizeMake(0,1);
label.shadowColor = [[UIColor blackColor] colorWithAlphaComponent:0.55];

您必须将 blackColor 替换为您想要的任何颜色。
我猜你不能模糊阴影,但你似乎不想那样。

UITextLabel *label = [[[UILabel alloc] init] autorelease];
label.shadowOffset = CGSizeMake(0,1);
label.shadowColor = [[UIColor blackColor] colorWithAlphaComponent:0.55];

You would have to replace the blackColor with whatever you want.
I guess that you cannot blur the shadow, but you seem not to want that anyway.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文