我们总会遇到使用UIAlertViewController
由于默认在一行显示,如果每行字数不一样造成字体大小每行不一致,展示上是很难看的
这时需要设置字体的一些方法
func setAlert(){
personAlert = UIAlertController.init(title: nil, message: nil, preferredStyle: .actionSheet)
let apperanceLabel = UILabel.appearance(whenContainedInInstancesOf: [UIAlertController.self])
apperanceLabel.numberOfLines = 0
for val in UserInfo.rightGroupId{
let setAct = UIAlertAction.init(title: val.organizationName + "-" + val.roleName, style: .default, handler: { (a) in
print(val.roleId,val.organizationId)
UserInfo.currentRoleId = val.roleId
UserInfo.currentOrganizationId = val.organizationId
UserInfo.userSave()
DispatchQueue.main.async {
let control = MainStoryboard.instantiateViewController(withIdentifier: "TabViewController") as! TabViewController
control.selectedIndex = 0
UIApplication.shared.delegate?.window??.rootViewController = control
UIApplication.shared.statusBarStyle = .default
}
})
setAct.setValue(UIColor.init(red: 51.0/255.0, green: 51.0/255.0, blue: 51.0/255.0, alpha: 1), forKey: "_titleTextColor")
personAlert.addAction(setAct)
}
let cancalAct = UIAlertAction.init(title: "取消", style: .cancel, handler: { (a) in
})
cancalAct.setValue(UIColor.init(red: 51.0/255.0, green: 51.0/255.0, blue: 51.0/255.0, alpha: 1), forKey: "_titleTextColor")
personAlert.addAction(cancalAct)
}
给予的支持:
网友评论