zoukankan      html  css  js  c++  java
  • 简单弹出视图

    #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
  • 相关阅读:
    ST表——————一失足成千古恨系列2
    五一清北学堂培训之图论
    最长上升子序列的教训———一失足成千古恨系列1
    五一清北学堂培训之Day 3之DP
    [bzoj1057][ZJOI2007]棋盘制作
    [bzoj1010][HNOI2008]玩具装箱TOY
    [bzoj2326][HNOI2011]数学作业
    如何使用矩阵乘法加速动态规划——以[SDOI2009]HH去散步为例
    [bzoj1060][zjoi2007]时态同步
    [bzoj1046][HAOI2007]上升序列
  • 原文地址:https://www.cnblogs.com/hl666/p/3701893.html
Copyright © 2011-2022 走看看