首页 > 其他 > 详细

UI基础 提示框

时间:2020-07-20 00:58:29      阅读:92      评论:0      收藏:0      [点我收藏+]

 

 

 

#import "RootViewController.h"

@interface RootViewController ()

@end

@implementation RootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    UIButton* button=[UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(10, 100, 120, 60);
    button.backgroundColor=[UIColor redColor];
    [self.view addSubview:button];
    [button addTarget:self action:@selector(touchme) forControlEvents:UIControlEventTouchUpInside];
   
}

-(void)touchme{
    
    // 提示框(新版)
    UIAlertController* control =[UIAlertController alertControllerWithTitle:@"友情提示" message:@"是否购买" preferredStyle:UIAlertControllerStyleAlert];
    
//        UIAlertController* control =[UIAlertController alertControllerWithTitle:@"友情提示" message:@"是否购买" preferredStyle:UIAlertControllerStyleActionSheet];
    
    //添加选项
//    UIAlertAction* act1=[UIAlertAction actionWithTitle:@"买" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//        NSLog(@"买了");
//    }];
    
//    UIAlertAction* act2=[UIAlertAction actionWithTitle:@"不买" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
//        NSLog(@"没钱");
//    }];
    
    // 红色的那个选项
//    UIAlertAction* act3=[UIAlertAction actionWithTitle:@"红色" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
//
//    }];
    
    
    
    
    //添加选项卡
//    [control addAction:act1];
//    [control addAction:act2];
//    [control addAction:act3];
    
    [self presentViewController:control animated:YES completion:^{
        NSLog(@"弹出来了");
    } ];
    //定时器 repeats Yes 表示间隔 时间运行 No表示只有一次
    [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timeOut) userInfo:nil repeats:YES];
    
   
    
}


-(void)timeOut{
    NSLog(@"取消提示框");
    [self dismissViewControllerAnimated:YES completion:^{
        
    }];
};
@end

 

UI基础 提示框

原文:https://www.cnblogs.com/zhangqing979797/p/13341942.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!