Add Uipickerview iOS8 replacement scheme on Uiactionsheet

Source: Internet
Author: User

This set of replacements is implemented in "uiview+ animation" (replacing Uiactionsheet with UIView)


The interface levels are as follows:

First layer: view (this layer fills the entire screen, the color is transparent when initialized,userinteractionenabled is no; the color is black when it is displayed, the alpha value is set to 0.6, Userinteractionenabled is yes. The effect is to obscure other controls on the interface. )

Second layer: Contentview (this layer is used to replace the original uiactionsheet. Uipickerview is added on this layer, the color is white, the alpha value is set to 0.9)

Layer Three: Uipickerview


The core code is as follows:

-(void) showpickerview{    self.userinteractionenabled = YES;    [UIView animatewithduration:0.3 delay:0.0 options:uiviewanimationoptioncurveeaseinout animations:^ (void) {        Self.backgroundcolor = [Uicolor colorwithred:0 green:0 blue:0 alpha:0.6];        [Self.contentview setframe:cgrectmake (0, Screen_size.height-picker.frame.size.height, 320, Picker.frame.size.height)];    } completion:^ (BOOL isfinished) {            }];} -(void) hidepickerview{    [UIView animatewithduration:0.3 delay:0.0 Options:uiviewanimationoptioncurveeaseinout animations:^ (void) {        Self.backgroundcolor = [Uicolor clearcolor];        [Self.contentview setframe:cgrectmake (0, Screen_size.height, Screen_size.width, Screen_size.height)];    } completion:^ (BOOL isfinished) {        self.userinteractionenabled = NO;    }];}

Note:

1. Self in the above code is the first layer of view.

2. It is best to encapsulate this function as a class, so that it can be used directly in multiple places.

Add Uipickerview iOS8 replacement scheme on Uiactionsheet

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.