zoukankan      html  css  js  c++  java
  • UIActionSheet上加入UIPickerView iOS8替换方案

    此套替换方案採用“UIView+动画”方式实现(将UIActionSheet替换为UIView)


    界面层级例如以下:

    第一层:view(这一层充满整个屏幕,初始化时颜色为透明。userInteractionEnabled 为NO。显示时颜色为黑色,alpha值设置为0.6,userInteractionEnabled 为YES。作用是遮挡界面上其它的控件。)

    第二层:contentView(这一层用来取代原来UIActionSheet。

    UIPickerView就加入在这一层上。颜色为白色,alpha值设置为0.9)

    第三层:UIPickerView


    核心代码例如以下:

    -(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;
        }];
    }

    注:

    1.上述代码中的self即为第一层的view。

    2.最好将这个功能封装成一个类,这样多个地方都用到的话就能够直接使用。

  • 相关阅读:
    一对多
    订单数据模型分析
    一对一查询(2)
    一对一查询
    Statement、PreparedStatemnt、CallableStatement
    getParameter和getAttribute的区别
    SQL基础试题
    Java 泛型(Generics) 综述
    <html>
    oracle视图建主键
  • 原文地址:https://www.cnblogs.com/yjbjingcha/p/7060592.html
Copyright © 2011-2022 走看看