UIActionsSheet文字阴影问题

发布于 2024-10-09 11:03:54 字数 372 浏览 5 评论 0原文

我对 UIActionSheet 按钮的文本阴影有疑问。在 iOS 4.0.2 中,长字符串会被自动截断。在 iOS 4.2 中,这些文本不会以较小的字体显示。但现在阴影的偏移已损坏且太大。

是否可以更改/删除 UIActionSheet 的文本阴影。 alt text

编辑:我不是使用 initWithTitle: 构建 UIActionSheet,而是使用正常的init 并随后设置所有需要的属性,因为可能的按钮数量是动态的并且文本无法更改。我用 initWithTitle: 对其进行了测试,并得到了相同的结果。

I have a problem with the text shadow of the UIActionSheet buttons. At iOS 4.0.2 long string were truncated automatically. No at iOS 4.2 these texts are presented with a smaller font. But now the offset of the shadow is corrupted and to big.

Is there a possibility to change/remove the text shadow of the UIActionSheet.
alt text

EDIT: I'm building the UIActionSheet not with initWithTitle:, but with the normal init and sets all needed properties afterwards because the number of possible buttons is dynamic and the texts cannot be change. I've tested it with initWithTitle: and got the same results.

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

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

发布评论

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

评论(4

时光病人 2024-10-16 11:03:54

您可以参考此来截断您的字符串在将其显示在 UIActionSheet 中之前。

You can refer this to truncate your string before displaying it in a UIActionSheet.

停滞 2024-10-16 11:03:54

我认为有两种解决方法(尽管我自己不会在我的应用程序中使用它们,原因在解决方法下面列出):

  • 在第一种情况下,您访问 UIActionSheet 的子层,获取标签,更改 shadowOffset 和 shadowColor 在呈现操作表之前。
  • 其次,您可以使用空白标题初始化操作表,并在操作表的正确位置添加您自己的标签作为子视图。 (比第一种方法更棘手)。

现在,第一种方法非常危险,因为苹果可以在将来的更新中更改 UIActionSheet 的层结构,因此您的应用程序可能会崩溃并且不会给出良好的结果。

仅当您可以计算出应放置标签的确切帧以使它们看起来不错时,继续使用第二种方法才是好的。但在您的情况下,按钮的数量也会有所不同,因此这种方法最初需要花费大量时间才能正常工作。

因此,在将字符串设置为按钮标题之前,我会先截断字符串。

不确定这会有多大帮助。但我确信在将字符串设置为标题之前截断字符串是最好的选择。

I can think there are two workarounds for this (although I would not them myself in my application, reason listed below the workarounds):

  • In the first case you access the sublayers of UIActionSheet, get the labels, change the shadowOffset and shadowColor before presenting the actionsheet.
  • Secondly you can initialize the actionsheet with blank titles and add your own labels as subviews on the actionsheet at right places. (More tricky then the first approach).

Now the first approach is very risky as the layer structure of UIActionSheet can be changed by apple in future updates, hence your application may break and would not give good results.

Continuing with second approach is good only when you can calculate the exact frames where you should put your lebels so that they look good. But in your case the number of buttons would also vary, so this approach will take a lot of time initially to get the things working.

Hence, I would go for truncating the strings before I set them as the title of buttons.

Not sure how much would this help. But I am sure that truncating strings before setting them as titles is the best option.

懷念過去 2024-10-16 11:03:54

您是否在执行任何非默认操作来显示文本?
如果您只使用 UIActionSheet-initWithTitle:... 您应该向 Apple 编写错误报告。
或者将文本缩短为“法兰克福国际 (FRA), DE”;)

are you doing anything non default for displaying the text?
If you only use UIActionSheet-initWithTitle:… you should write a bug report to Apple.
OR shorten the text to "Frankfurt International (FRA), DE" ;)

疯了 2024-10-16 11:03:54

这似乎在 4.30 中得到了修复。我发现在 4.2x 中没有办法修复它。

This appears to be fixed in 4.30. I found no way of fixing it in 4.2x.

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