在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
let alert = UIAlertController(title: "", message: "", preferredStyle: UIAlertController.Style.alert) ///标题颜色/字体 let titleAtt = NSMutableAttributedString(string: "删除会员卡", attributes: [NSAttributedString.Key.font : UIFont.systemFont(ofSize: 16, weight: UIFont.Weight.regular), NSAttributedString.Key.foregroundColor:UIColor.init(hexString: "#000000")]) alert.setValue(titleAtt, forKey: "attributedTitle") let paragraph = NSMutableParagraphStyle() //设置字体2
let subView1 = alert.view.subviews[0] let subView2 = subView1?.subviews[0] let subView3 = subView2?.subviews[0] let subView4 = subView3?.subviews[0] let subView5 = subView4?.subviews[0] var title_lb: UILabel? var message_lb: UILabel?
///subView5.subviews[2] 是label ,就是真机的 if subView5?.subviews[2].classForCoder == UILabel.classForCoder { ///真机subView5.subviews.count 是5 title_lb = subView5?.subviews[1] as? UILabel ///title message_lb = subView5?.subviews[2] as? UILabel ///message } else { //模拟器 subView5.subviews.count 是4 title_lb = subView5?.subviews[0] as? UILabel ///title message_lb = subView5?.subviews[1] as? UILabel ///message } title_lb?.textAlignment = .right message_lb?.textAlignment = textAlignment
参考链接 |
请发表评论