UIActionSheet / UIAlertController多行文本

编程入门 行业动态 更新时间:2024-10-08 13:31:56
本文介绍了UIActionSheet / UIAlertController多行文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这是我写的代码,用于显示 UIActionSheet 。

This is the code I am writing to display UIActionSheet.

actionSheet = [[UIActionSheet alloc] initWithTitle:NSLocalizedString(@"updateresponseforrecurring", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) destructiveButtonTitle:nil otherButtonTitles: NSLocalizedString(@"updateresponseonlyforthis", nil), NSLocalizedString(@"updateresponseforallactivities", nil), nil]; actionSheet.tag = 2; [actionSheet showInView:[UIApplication sharedApplication].keyWindow];

这是我得到的:

显然,第二个选项较长,因此尺寸变小以适应宽度。 但我希望所有选项都使用相同的字体大小,这样我就可以使用多行。还尝试使用 UIAlertController ,但无法设置多行文字。 如何实现这一目标?

Clearly, second option is longer and thus the size gets smaller to accommodate the width. But I want the same font size for all the options which leaves me with multiline. Also tried with UIAlertController but not able to set multiline text. How to achieve this ?

推荐答案

这似乎适用于iOS 10和Swift 3.1:

This seems to work in iOS 10 and Swift 3.1:

UILabel.appearance(whenContainedInInstancesOf: [UIAlertController.self]).numberOfLines = 2

更多推荐

UIActionSheet / UIAlertController多行文本

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

发布评论

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

>www.elefans.com

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