iOS 菊花效果
先下载第三方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
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。