Showing posts with label Activity Indicator view related.... Show all posts
Showing posts with label Activity Indicator view related.... Show all posts

28 Mar 2017

Activity Indicator View (Custom Spinner)...



Activity Indicator View (Custom Spinner)...


          



#import "ViewController.h"

@interface ViewController ()
{
    UIActivityIndicatorView *activityIndicator;
}

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

  UIButton *startBtn = [UIButton buttonWithType:UIButtonTypeCustom];

    startBtn.frame = CGRectMake(40, 150, 60, 40);

    startBtn.backgroundColor = [UIColor purpleColor];

    startBtn.layer.borderWidth = 2;

    startBtn.layer.borderColor = [UIColor greenColor].CGColor;
    [startBtn setTitle:@"Start" forState:UIControlStateNormal];
    [startBtn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    startBtn.layer.cornerRadius = 10;
    [startBtn addTarget:self action:@selector(sartBtnAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:startBtn];
    
    
    UIButton *stopBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    stopBtn.frame = CGRectMake(200, 150, 60, 40);
    stopBtn.backgroundColor = [UIColor purpleColor];
    stopBtn.layer.borderWidth = 2;
    stopBtn.layer.borderColor = [UIColor greenColor].CGColor;
    [stopBtn setTitle:@"Stop" forState:UIControlStateNormal];
    [stopBtn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    stopBtn.layer.cornerRadius = 10;
    [stopBtn addTarget:self action:@selector(stopBtnAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:stopBtn];

     activityIndicator = [[UIActivityIndicatorView alloc]
                                             initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
    
    [activityIndicator setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleGray];
    activityIndicator.color = [UIColor redColor];
    activityIndicator.transform = CGAffineTransformMakeScale(5, 5);
    //    activityView.layer.borderWidth = 2.0;
    //    activityView.layer.borderColor = [UIColor greenColor].CGColor;
    
    //activityView.frame = CGRectMake(120, 230, 100,100);
    activityIndicator.center=self.view.center;

    [self.view addSubview:activityIndicator];
    activityIndicator.hidden = NO;
    
 }



- (void) sartBtnAction {
    
    [activityIndicator startAnimating];
    activityIndicator.color = [UIColor blueColor];
    
}

- (void) stopBtnAction {
    
    [activityIndicator stopAnimating];
    activityIndicator.color = [UIColor greenColor];
    activityIndicator.hidden = NO;
}


@end



Recent Posts

Codable demo

Link: https://www.dropbox.com/s/kw7c1kgv1628bh7/codableDemo.zip?dl=0