我正在试图弄清楚如何更改UIAlertAction标题的字体类型.我假设,可以通过设置特定键的值来完成.例如,要设置图像,您可以这样做:
action.setValue(image, forKey: "image")
Run Code Online (Sandbox Code Playgroud)
是否有可用的所有密钥列表?我无法弄清楚用于更改字体的哪个键,左/右对齐标题等...
我正在尝试更改使用UIAlertController显示的警报的标题和消息字体我正在尝试使用NSAttributedStirng,但它给编译器错误,无法取代NSAttributed字符串而不是Stirng我尝试了类似于此的东西
var title_attrs = [NSFontAttributeName : CustomFonts.HELVETICA_NEUE_MEDIUM_16]
var msg_attrs = [NSFontAttributeName : CustomFonts.HELVETICA_NEUE_REGULAR_14]
var title = NSMutableAttributedString(string:"Done", attributes:title_attrs)
var msg = NSMutableAttributedString(string:"The job is done ", attributes:msg_attrs)
let alertController = UIAlertController(title: title, message: title , preferredStyle: UIAlertControllerStyle.Alert)
Run Code Online (Sandbox Code Playgroud)
有人可以指导我如何实现这一目标?
我试图更改标题fontSize中的UIAlertController,但我不能管理如何我设置NSMutableAttributedString的title-属性。
所以我一直在NSMutableAttributedString使用以下代码创建:
let title = NSMutableAttributedString(string: user.fullName)
let range = NSRange(location: 0, length: title.length)
title.addAttribute(NSAttributedStringKey.font, value: UIFont.TextStyle.largeTitle, range: range)
Run Code Online (Sandbox Code Playgroud)
现在对我来说棘手的部分是如何弄清楚如何将新标题设置为UIAlertController,因为它需要一个String?值。
我环顾四周,发现UILabel在呈现UIAlertController. 但是如何使用我自己的自定义覆盖title-property ?UIAlertControllerUILabel
present(myUIAlertController, animated: true) {
// Creating the UILabel depending on string length
// Set the NSMutableAttributedString value to the custom UILabel and override title property.
}
Run Code Online (Sandbox Code Playgroud)
或者也许有更简单的方法来解决这个问题?
nsmutableattributedstring swift uialertviewcontroller swift4
https://www.safaribooksonline.com/library/view/ios-8-swift/9781491908969/images/ispc_0113.png
在上图中如何更改"完成","其他动作"的字体大小和颜色?以及如何更改"标题"和"消息"的字体大小和颜色?
谢谢.
我有一个UIAlertController,我有一堆UIAlertAcion按钮.现在我需要显示一个带有其他颜色而不是相同颜色的按钮.
对于Ex
Button1的
BUTTON2
BUTTON3
Button1和button3应为蓝色
和
button2应为红色.
可能吗 ?怎么样?
只是扔你的想法......
我的代码:
UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:@"Food Menu" message:@"Select the MenuItem" preferredStyle:UIAlertControllerStyleActionSheet];
for(int i= 0; i<[menus count];i++){
UIAlertAction *action = [UIAlertAction actionWithTitle:[menu objectAtIndex:i] style:UIAlertActionStyleDefault handler:^(UIAlertAction* action){
[actionSheet dismissViewControllerAnimated:YES completion:nil];
//do SomeWork
}];
if(i==currentIndex){
//Put button Color Red
}
else{
//put button color Blue
}
[actionSheet addAction:action];
}
UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction* action){
[actionSheet dismissViewControllerAnimated:YES completion:nil];
}];
[actionSheet addAction:cancel];
[self presentViewController:actionSheet animated:YES completion:nil];
}
Run Code Online (Sandbox Code Playgroud) 是否可以为取消和其他操作按钮提供单独的色调颜色?目前我正在改变色调颜色controller.view.tintColor = [UIColor blackColor];
但它也改变了取消按钮的色调颜色.我需要设置不同的色调颜色,说红色到取消按钮.请帮帮我们.
我正在制作 Android 应用程序的 iOS 版本。我想让我正在通过的字符串变成粗体。在另一个应用程序中,它是通过添加 html 来完成的,如下所示。我尝试了这个,但没有成功。有没有办法实现这个或可能解决这个问题?
旁注:showPrompt 是我为 UIAlertController 功能所做的开关。
谢谢,
func systemUpdateCheck(oCurVer: String){
showPrompt("A new version has been released,<b>v." + oCurVer + "<b>.<br/>Tap OK to download and install the new version", sType: "alert", sJSResp: "")
}
Run Code Online (Sandbox Code Playgroud) 是否有办法为uialertview中的某些特定单词着色?我的意思是,我可以将RED这个词换成红色,同时将GREEN换成绿色吗?

有人能以正确的方式带我吗?