Generally, when customizing a system control, subviews in the control should be traversed.
[Html]
-(Void) willPresentAlertView :( UIAlertView *) alertView {
For (UIView * view in [alertView subviews])
{
// Determine if it is UILabel
If ([[[view class] description] isEqualToString: @ "UILabel"])
{
// Customize UILabel
}
// Determine if it is UIButton
If ([[view class] description] isw.tostring: @ "UIAlertButton"]
| [[View class] description] isEqualToString: @ "UIThreePartButton"])
{
// Customize UIButton
}
}
}
When you use the [[view class] description] isEqualToString: @ "UIAlertButton"] method to determine whether the current View is a button, there is a drawback, because [[view class] description] has different descriptions on different devices, you can use UIAlertButton or UIThreePartButton in the above method. Of course, there are even more.
In fact, you can use [view isKindOfClass: NSClassFromString (@ "UIButton")] to determine whether to differentiate devices. The modified method is as follows:
[Html]
-(Void) willPresentAlertView :( UIAlertView *) alertView {
For (UIView * view in [alertView subviews])
{
// Determine if it is UILabel
If ([view isKindOfClass: NSClassFromString (@ "UILabel")])
{
// Customize UILabel
}
// Determine if it is UIButton
If ([view isKindOfClass: NSClassFromString (@ "UIButton")])
{
// Customize UIButton
}
}
}