美文网首页
iOS 选择框,自定义选择

iOS 选择框,自定义选择

作者: BeeQiang | 来源:发表于2017-10-24 15:11 被阅读0次

    先上图

    附上地址 https://github.com/liwq87112/WQAlertView

    B34F6273-A32A-4FCC-8040-675A5FB7FE03.png

    里面的cell可以自定义·背景·颜色,按钮都可以

    NSArray * arr = @[@"喜欢吗",@"欢迎下载",@"WQAlertView"];
    self.alert = [WQAlertView tableAlertWithTitle:@"" cancelButtonTitle:@"" numberOfRows:^NSInteger(NSInteger section) {
            //返回多少个
            return arr.count;
        } andCells:^UITableViewCell *(WQAlertView *alert, NSIndexPath *indexPath) {
            //自定义cell
            static NSString *CellIdentifier = @"CellIdentifier";
            UITableViewCell *cell = [anAlert.table dequeueReusableCellWithIdentifier:CellIdentifier];
            if (cell == nil)
            {cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];}
            cell.textLabel.text = arr[indexPath.row];
            return cell;
    
        }];
     [self.alert show];
    

    显示和消失的时候做啦一点动画视觉效果

    消失

    -(void)animateOut
    {
        [UIView animateWithDuration:1.0/7.5 animations:^{
            self.alertBg.transform = CGAffineTransformMakeScale(0.9, 0.9);
        } completion:^(BOOL finished) {
            [UIView animateWithDuration:1.0/15.0 animations:^{
                self.alertBg.transform = CGAffineTransformMakeScale(1.1, 1.1);
            } completion:^(BOOL finished) {
                [UIView animateWithDuration:0.3 animations:^{
                    self.alertBg.transform = CGAffineTransformMakeScale(0.01, 0.01);
                    self.alpha = 0.3;
                } completion:^(BOOL finished){
                    [self removeFromSuperview];
                }];
            }];
        }];
    }
    

    显示

    -(void)animateIn
    {
        self.alertBg.transform = CGAffineTransformMakeScale(0.6, 0.6);
        [UIView animateWithDuration:0.2 animations:^{
            self.alertBg.transform = CGAffineTransformMakeScale(1.1, 1.1);
        } completion:^(BOOL finished){
            [UIView animateWithDuration:1.0/15.0 animations:^{
                self.alertBg.transform = CGAffineTransformMakeScale(0.9, 0.9);
            } completion:^(BOOL finished){
                [UIView animateWithDuration:1.0/7.5 animations:^{
                    self.alertBg.transform = CGAffineTransformIdentity;
                }];
            }];
        }];
    }
    

    如果你觉得还行·欢迎下载 demo https://github.com/liwq87112/WQAlertView

    相关文章

      网友评论

          本文标题:iOS 选择框,自定义选择

          本文链接:https://www.haomeiwen.com/subject/lfotpxtx.html