The Uiactionsheet in iOS offers only a handful of styles in the SDK that basically meet the development requirements, but also encounter more cumbersome requirements, which require a separate custom uiactionsheet to modify the button's properties. If it is iOS4 or the previous version of the operation is more complex, but ios5 after the Uiactionsheet button replaced by UIButton type after easier, can directly facilitate all uiactionsheet Subview, Find the corresponding button can modify its properties, implementation is very simple, it should be noted that the button in the button list in the Uiactionsheet index ID can directly use the Tag property directly to obtain, it is very convenient to find them
Reference code;
The code is as follows |
Copy Code |
-(void) Willpresentactionsheet: (Uiactionsheet *) Actionsheet { if ([[[[[Uidevice Currentdevice] systemversion] floatvalue] > 4.9) { For (UIView *view in actionsheet.subviews) { if (View.tag = = 2) { UIButton *button = (UIButton *) view; Change the background [Button Setbackgroundimage:[button backgroundimageforstate:uicontrolstatehighlighted] ForState: UIControlStateNormal]; Change color [Button Settitlecolor:[uicolor Whitecolor] forstate:uicontrolstatenormal]; BTN selection state, otherwise select unchanged background [Button Setselected:yes]; } else { } }
} else { IOS4 before the release button is not inherited from UIButton but Uithreepartbutton For (UIView *view in actionsheet.subviews) { if (View.tag = = 2) { Uicontrol *btn = (Uicontrol *) view; [Btn Setselected:yes]; } else { } } } } |