基本コントロール

3542 ワード

ボタン
//    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(0, 0, 200, 40);
    button.center = self.view.center;
    // 
    [button setTitle:@" " forState:UIControlStateNormal];
    [button setTitle:@"button" forState:UIControlStateSelected];
    // 
    button.layer.cornerRadius = 10;
    //  。
    [button setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];
    // 
    [button addTarget:self action:@selector(action_button:) forControlEvents:UIControlEventTouchUpInside];
    button.backgroundColor = [UIColor yellowColor];

pagecontrol
- (UIPageControl *)pagecontrol{
    if (_pagecontrol == nil){
        _pagecontrol = [[UIPageControl alloc]initWithFrame:CGRectMake(Screen_Width * 2.3, Screen_Height * 0.6, Screen_Width * 0.4, 30)];
        _pagecontrol.numberOfPages = 3;
        _pagecontrol.currentPage = 0;
        }
    return _pagecontrol;
}

セグメントコントローラ
- (UISegmentedControl *)segmentConrol{
    if (!_segmentConrol) {
        _segmentConrol = [[UISegmentedControl alloc]initWithItems:@[@" ",@" ",@" ",@" "]];
        _segmentConrol.frame = CGRectMake(0, 0, 300, 30);
        _segmentConrol.center = CGPointMake(self.view.center.x, 40);
        _segmentConrol.backgroundColor = [UIColor whiteColor];
        // 
        _segmentConrol.selectedSegmentIndex = 0;
        [_segmentConrol addTarget:self action:@selector(action_swithControl:) forControlEvents:UIControlEventValueChanged];
    }
    return _segmentConrol;
}

スライドバー
- (UISlider *)slider{
    if (!_slider) {
        //  , 
        _slider = [[UISlider alloc]initWithFrame:CGRectMake(0, 0, 300, 30)];
        _slider.center = CGPointMake(self.view.center.x, 300);
        // 
        _slider.value = 1.0;
        [_slider addTarget:self action:@selector(action_swithControl:) forControlEvents:UIControlEventValueChanged];
    }
    return _slider;
}

進捗バー
- (UIProgressView *)progressview{
    if (!_progressview) {
        _progressview = [[UIProgressView alloc]initWithFrame:CGRectMake(0, 0, 300, 30)];
        _progressview.center = CGPointMake(self.view.center.x, 500);
        // 
        _progressview.progress = 1.0;
        // 
        _progressview.progressTintColor = [UIColor redColor];
        _progressview.trackTintColor = [UIColor yellowColor];
    }
    return _progressview;
}

アクティブインジケータ
- (UIActivityIndicatorView *)indicatorview{
    if (!_indicatorview) { // 。 getter。
        //  , 
        _indicatorview = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
        _indicatorview.center = self.view.center;
        // 
        [_indicatorview startAnimating];
        //  , 。
//        _indicatorview.hidesWhenStopped = YES;
    }
    return _indicatorview;
}

スイッチ
- (UISwitch *)switchControl{
    if (!_switchControl) {
        // 
        _switchControl = [[UISwitch alloc]init];
        _switchControl.center = CGPointMake(200, 200);
        _switchControl.thumbTintColor = [UIColor redColor];// 。
        _switchControl.tintColor = [UIColor orangeColor];//  
        // 
        _switchControl.on = YES;
        //  
        [_switchControl addTarget:self action:@selector(action_swithControl:) forControlEvents:UIControlEventValueChanged];
    }
    return _switchControl;
}