Tag: uialertcontroller

在Swift中破解iOS警报

更新:添加了附件图像和附件视图🙂 大家好! 这是我的第一篇中篇文章,所以希望对此做出有趣的贡献。 😉 如果您使用过Swift和/或UIKit iOS框架,则可能曾经想过显示警报,并可能使用过UIAlertController 。 事实是,此类不是非常可定制的,您几乎不能更改其色调颜色,并且不能做更多的事情…… 因此,我开始研究如何使其变暗或更改字体……但是我意识到最好的方法就是制作自己的警报 。 话虽如此……与Apple私有API或内部值:D混在一起仍然真的很酷,因此,这只是一堆Swift’hacks’,很有趣,可以使UIAlertController更可定制。 发出上述警报的代码很简单: 但是什么是DarkAlertController? 只是CustomizableAlertController的子类。 如此简单, CustomizableAlertController具有视觉效果的属性,以及一些可以轻松更改标题和消息的文本属性的属性。 (您可以在github中查看完整的实现)。 您还可以像这样轻松更改警报背景: alert.contentView?.backgroundColor = .red 如何设置标题和消息文本属性? 只需使用KVC更改属性即可: 警报。 setValue (newValue,forKey:“ attributedTitle ”) 警报。 setValue (newValue,forKey:“ attributedMessage ”) 警报动作归因于文本? 有点棘手; 您首先需要标签,然后使用attributedText属性: var标签:UILabel? { 回报(自我。 值 ( forKey :“ __representer ”)为? NSObject)? 。 值 ( forKey :“ label ”)为? UILabel } […]

使用ALRT轻松创建UIAlertController

Dejavu? 您需要不时创建一个UIAlertController。 经过几行之后,您开始意识到自己之前已经编写了类似的代码。 编写步骤并不困难, 但乏味而乏味 。 这就是为什么几年前我创建ALRT的原因,它是UIAlertController的一种更简单的构造函数。 ALRT如何工作? 让我们通过示例来指导您。 典型的步骤就是这样。 使用ALRT,您只需一行即可获得相同的结果。 用法页面涵盖了其他常见的用例。 如何开始? 迦太基和可可足都被支持。 迦太基 github的“ mshrwtnb / ALRT”〜> 1.3.2 椰子足 吊舱回购更新 pod’ALRT’,’〜> 1.3.2′ – 享受ALRT https://github.com/mshrwtnb/ALRT

UIAlertController更改其他UIView

我花了很多时间,但我无法弄清楚如何解决这个问题。 我做了一个从底部出现的select器视图。 它工作正常,但问题是当任何其他事件显示警报视图。 同一时间select器视图从顶部。 注意 。 警报视图出现之前。 select器视图工作正常。 在警报视图出现之后,piker视图到达顶部。 底部出现piker view code: extension RegistrationController { func showSettings(selecteIndex : Int) { //show menu if let window = UIApplication.shared.keyWindow { blackView.backgroundColor = UIColor(white: 0, alpha: 0.5) blackView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(handleDismiss))) window.addSubview(blackView) window.addSubview(bottomView) bottomView.addSubview(titlebottomView) titlebottomView.addSubview(bottomViewActionLabel) titlebottomView.addSubview(doneButton) let height: CGFloat = 150 let y = window.frame.height – height bottomView.frame […]

UIAlertcontroller作为Swift中的一个动作

所以我想要popup一个警告,告诉我一个消息,然后我希望它等待我,直到我按下确定,然后它将继续与该function。 例如。 @IBAction Alert() { let alertController = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.Alert) alertController.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil)) self.presentViewController(alertController, animated: true, completion: nil) } 问题是,现在它不会做任何事情,如果我只是把它放在一个函数,它直接做,而不是等到我按下OK。 有谁知道如何做到这一点? 顺便说一下,在这个例子中,这个消息将是标题,消息,我知道,这不是我需要在这种情况下;) 提前致谢!

Swift – UIAlertcontrller上textfield的大小

我想增加UIAlertController的UITextField的初始高度。 这是我的代码: let reportAlertController = UIAlertController(title: "Report", message: "If you find anything to report, please write it in the text box below and press send. To cancel report, press cancel.", preferredStyle: .Alert) reportAlertController.addTextFieldWithConfigurationHandler({ (tf) -> Void in tf.frame.size.height = 1500 tf.placeholder = "Report detail(s) here" }) reportAlertController.addAction(UIAlertAction(title: "Send", style: UIAlertActionStyle.Default, handler: nil)) reportAlertController.addAction(UIAlertAction(title: "Cancel", style: […]

AlertController中的Html文件?

我可以在UIAlertController中显示html文件的内容吗? 我有一个服务条款的文本,我已经格式化在一个HTML文件。 我希望能够在用户input应用程序时在AlertView中显示,以便他们必须单击确定。

UIAlertAction的处理程序有点太迟了 – 我怎么能立即做到这一点?

我正在尝试(…)为添加到UIAlertController的button添加声音效果。 我在处理程序中发出了一个声音效果,但实际上有点太迟了。 声音像0.5秒太晚了。 警报即将解散后 ,我希望声音能够解除,而不是在解散之后解除。 使用UIAlertView可以处理使用alertWillDismiss …而不是alertDidDismiss。 我错过了什么?

iOS UIAlertController代码stream控制

-(bool)textFieldShouldClear:(UITextField *)textField { UIAlertController * blert = [UIAlertController alertControllerWithTitle:@"your alert" message:@"are you sure you want to clear" preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction * defautact = [UIAlertAction actionWithTitle:@"ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action){ NSLog(@"tao on YES"); // click= YES; _baba =@"yes"; }]; UIAlertAction * defautact1 = [UIAlertAction actionWithTitle:@"cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action){ NSLog(@"Press on YES"); // click= NO; //field1.text=@""; _baba=@"no"; […]

如何编辑UIAlertActionbutton的字体大小

现在我正在使用UIAlertController,我试图改变操作button的字体大小(确定和取消),但我还没有find任何解决scheme。 任何人都可以提供一个解决scheme 谢谢

UIAlertController更改操作表的“取消”button的背景颜色

我想创build一个UIAlertController的动作表风格,但我想要将背景颜色更改为灰色。 我已经能够find一种方法来更改UIAlertController的背景颜色,而不是取消button。 取消button,单独,保持白色。 这是我现在的代码: UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet]; [alert addAction:[UIAlertAction actionWithTitle:@"Option 1" style:UIAlertActionStyleDefault handler:nil]]; [alert addAction:[UIAlertAction actionWithTitle:@"Option 2" style:UIAlertActionStyleDefault handler:nil]]; [alert addAction:[UIAlertAction actionWithTitle:@"Option 3" style:UIAlertActionStyleDefault handler:nil]]; [alert addAction:[UIAlertAction actionWithTitle:@"Delete" style:UIAlertActionStyleDestructive handler:nil]]; [alert addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]]; UIView *firstSubview = alert.view.subviews.firstObject; UIView *alertContentView = firstSubview.subviews.firstObject; for (UIView *subSubView in alertContentView.subviews) { subSubView.backgroundColor = […]