码迷,mamicode.com
首页 > 移动开发 > 详细

iOS 菊花效果

时间:2015-04-13 16:50:55      阅读:157      评论:0      收藏:0      [点我收藏+]

标签:

先下载第三方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 {

    [super viewDidLoad];

    // Do any additional setup after loading the view.

    

    self.view.backgroundColor = [UIColor whiteColor];

    

    

    self.changeBtn = [UIButton buttonWithType:(UIButtonTypeSystem)];

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

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

    [self.changeBtn addTarget:self action:@selector(didChangeBtnActionL:) forControlEvents:(UIControlEventTouchUpInside)];

    [self.view addSubview:self.changeBtn];

    

    

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

    self.labelOne.text = @"hello";

    [self.view addSubview:self.labelOne];

    

    self.playBtn = [UIButton buttonWithType:(UIButtonTypeSystem)];

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

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

    [self.playBtn addTarget:self action:@selector(didplayBrtn) forControlEvents:(UIControlEventTouchUpInside)];

    [self.view addSubview: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 = [[MBProgressHUD alloc] initWithFrame:CGRectMake(60, 100, 60, 60)];

    [self.view addSubview:_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

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


    


}


- (void)myTask

{



    sleep(3);





}


- (void)didplayBrtn

{



    NSLog(@"heloo1");

 

    SecondViewController *secondVC = [[SecondViewController alloc] init];

    [self.navigationController pushViewController:secondVC animated:YES];


}


- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];

    // 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


技术分享

iOS 菊花效果

标签:

原文地址:http://blog.csdn.net/zhaoguodongios/article/details/45025127

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!