博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
简单弹出视图
阅读量:4681 次
发布时间:2019-06-09

本文共 2598 字,大约阅读时间需要 8 分钟。

#import "loveView.h"//点击按钮-(void)buttonclick{UIWindow *window = [UIApplication sharedApplication].keyWindow;loveView *loveview = [[loveView alloc] initWithFrame:window.bounds];loveview.alpha = 0;[window.rootViewController.view addSubview:loveview];[UIView animateWithDuration:0.5                 animations:^{        loveview.alpha = 1.0;    } ];}

  

#import "loveView.h"@implementation loveView- (id)initWithFrame:(CGRect)frame{    self = [super initWithFrame:frame];    if (self) {        // Initialization code                [self   creatView];            }    return self;}-(void)creatView{    [self setBackgroundColor:[UIColor clearColor]];        UIView *backView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 568)];    backView.center = self.center;    [backView setBackgroundColor:[UIColor blackColor]];    [self addSubview:backView];    backView.alpha = 0.3;        UIView *mainView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 280, 200)];    mainView.center = self.center;    [mainView setBackgroundColor:[UIColor whiteColor]];    [self addSubview:mainView];            UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 10,260, 50)];    label.text = @"   Love Me?那就告诉全世界吧!";    label.backgroundColor = [UIColor clearColor];    label.textAlignment = NSTextAlignmentCenter;    label.textColor = [UIColor  blueColor];        UIButton *yesBtn = [[UIButton alloc] initWithFrame:CGRectMake(10, 60, 260, 50)];    [yesBtn setBackgroundColor:[UIColor  greenColor]];    [yesBtn setTitle:@"好!" forState:UIControlStateNormal];    [yesBtn setTitleColor:[UIColor  redColor] forState:UIControlStateNormal];    [yesBtn addTarget:self action:@selector(yesBtnClick) forControlEvents:UIControlEventTouchUpInside];        UIButton *noBtn = [[UIButton alloc] initWithFrame:CGRectMake(10, 130, 260, 50)];    [noBtn setBackgroundColor:[UIColor redColor]];    [noBtn setTitle:@"不,谢谢" forState:UIControlStateNormal];    [noBtn addTarget:self action:@selector(noBtnClick) forControlEvents:UIControlEventTouchUpInside];        [mainView addSubview:label];    [mainView addSubview:yesBtn];    [mainView addSubview:noBtn];}- (void)yesBtnClick{        NSLog(@"YES!!!");    [UIView animateWithDuration:0.5 animations:^{                self.alpha = 0.0;    } completion:^(BOOL finished) {        [self removeFromSuperview];    }];}- (void)noBtnClick{    NSLog(@"NO!!!");    [UIView animateWithDuration:0.5 animations:^{                self.alpha = 0.0;            } completion:^(BOOL finished) {        [self removeFromSuperview];    }];    }@end

 

转载于:https://www.cnblogs.com/hl666/p/3701893.html

你可能感兴趣的文章
django考点
查看>>
python-socket
查看>>
Android中intent如何传递自定义数据类型
查看>>
android基础---->子线程更新UI
查看>>
SharedPreferences
查看>>
转载 线程池之ThreadPool类与辅助线程 - <第二篇>
查看>>
js获取元素样式
查看>>
合并排序(C语言实现)
查看>>
sql 计算两时间或日期 的相差的 年、 月、 日、时、分、秒,年、月、日分别的提取...
查看>>
HDU 1176免费馅饼 DP数塔问题转化
查看>>
十进制二进制转换
查看>>
shiro实战系列(七)之Realm
查看>>
超像素、语义分割、实例分割、全景分割 傻傻分不清?
查看>>
HMM学习
查看>>
Mysql扩展之replication概述
查看>>
C++中数值的后缀
查看>>
EventModify
查看>>
C中int8_t、int16_t、int32_t、int64_t、uint8_t、size_t、ssize_t区别
查看>>
python day2 模块初识、pyc定义
查看>>
一道算法作业题(续)
查看>>