在项目中,有时候我们需要修改UIAlertController上标题和消息的样式。这就需要找到标题和消息内容所在的标签控件,进行操作。下面介绍如何获取这两个控件:
UIView *subView1 = alertVC.view.subviews[0];
UIView *subView2 = subView1.subviews[0];
UIView *subView3 = subView2.subviews[0];
UIView *subView4 = subView3.subviews[0];
UIView *subView5 = subView4.subviews[0];
标题控件
UILabel *title = subView5.subviews[0];
消息内容控件
UILable *message = subView5.subviews[1];