iOS 菊花效果

来源:互联网 发布:如何代销淘宝产品 编辑:程序博客网 时间:2024/04/28 15:21

先下载第三方MBProgressHUD并且引入MBProgressHUD.和MBProgressHUD.m:


//  RootViewController.m

//  MBProgressDemo

//

//  Created by Dubai on 15/4/13.

//  Copyright (c) 2015 Dubai. All rights reserved.

//


#import "RootViewController.h"


#import "MBProgressHUD.h"


#import "SecondViewController.h"//第二个页面



@interface RootViewController ()<MBProgressHUDDelegate>



@property (strong,nonatomic) UIButton *changeBtn;//改变颜色


@property (strong,nonatomic) UIButton *playBtn;//能否有交互


@property (strong,nonatomic) UILabel *labelOne;


@end


@implementation RootViewController


- (void)viewDidLoad {

    [superviewDidLoad];

    // Do any additional setup after loading the view.

    

    self.view.backgroundColor = [UIColorwhiteColor];

    

    

    self.changeBtn = [UIButtonbuttonWithType:(UIButtonTypeSystem)];

   self.changeBtn.frame =CGRectMake(60,100, 60, 40);

    [self.changeBtnsetTitle:@"改变"forState:(UIControlStateNormal)];

    [self.changeBtnaddTarget:selfaction:@selector(didChangeBtnActionL:)forControlEvents:(UIControlEventTouchUpInside)];

    [self.viewaddSubview:self.changeBtn];

    

    

    self.labelOne = [[UILabelalloc] initWithFrame:CGRectMake(60,400, 60, 40)];

   self.labelOne.text =@"hello";

    [self.viewaddSubview:self.labelOne];

    

    self.playBtn = [UIButtonbuttonWithType:(UIButtonTypeSystem)];

   self.playBtn.frame =CGRectMake(100,300, 60, 40);

    [self.playBtnsetTitle:@"123"forState:(UIControlStateNormal)];

    [self.playBtnaddTarget:selfaction:@selector(didplayBrtn)forControlEvents:(UIControlEventTouchUpInside)];

    [self.viewaddSubview:self.playBtn];

    

}



- (void)didChangeBtnActionL:(UIButton *)sender

{


//    _HUD = [[MBProgressHUD alloc] initWithFrame:CGRectMake(60, 100, 60, 60)];

//    [self.view addSubview:_HUD];

//    

//    // Set the hud to display with a color

//    _HUD.color = [UIColor colorWithRed:0.23 green:0.50 blue:0.82 alpha:0.90];

//    

//    _HUD.delegate = self;

//    [_HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES];

//


    

   _HUD = [[MBProgressHUDalloc] initWithFrame:CGRectMake(60,100, 60, 60)];

    [self.viewaddSubview:_HUD];

    

    _HUD.dimBackground =YES;

    

    // Regiser for HUD callbacks so we can remove it from the window at the right time

    _HUD.delegate =self;

    

    // Show the HUD while the provided method executes in a new thread

    [_HUDshowWhileExecuting:@selector(myTask)onTarget:selfwithObject:nilanimated:YES];


    


}


- (void)myTask

{



   sleep(3);





}


- (void)didplayBrtn

{



    NSLog(@"heloo1");

 

    SecondViewController *secondVC = [[SecondViewControlleralloc] init];

    [self.navigationControllerpushViewController:secondVC animated:YES];


}


- (void)didReceiveMemoryWarning {

    [superdidReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}


/*

#pragma mark - Navigation


// In a storyboard-based application, you will often want to do a little preparation before navigation

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    // Get the new view controller using [segue destinationViewController].

    // Pass the selected object to the new view controller.

}

*/


@end



0 0
原创粉丝点击