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
  • 相关阅读:
    sed 简明教程
    简明 Vim 练级攻略
    AWK 简明教程
    TCP 的那些事儿(下)
    TCP 的那些事儿(上)
    CentOS 7系统安装配置图解教程
    Google Chrome谷歌/火狐/Safari浏览器开发者工具基本使用教程
    《Ext JS模板与组件基本框架图----组件》
    ExtJS关于组件Component生命周期
    《Ext JS模板与组件基本知识框架图----模板》
  • 原文地址:https://www.cnblogs.com/hl666/p/3701893.html
Copyright © 2011-2022 走看看