国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

ios中addtarget的用法

2019-11-14 19:50:19
字體:
來源:轉載
供稿:網友

 1.addtarget 的。部分使用事件沒有直接的操作方式,需要進行調用。就要用addTarget。

- (void)setupCustomView {

    

    self.customView = [[CHView alloc] init];

    self.customView.translatesAutoresizingMaskIntoConstraints = NO;

    

    [self.view addSubview:self.customView];

    

    NSDictionary *viewsDictionary = @{ @"topLayoutGuide": self.topLayoutGuide,

                                       @"customView": self.customView

                                       };

    [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[topLayoutGuide][customView]|"

                                                                      options:0

                                                                      metrics:nil

                                                                        views:viewsDictionary]];

    [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[customView]|"

                                                                      options:0

                                                                      metrics:nil

                                                                        views:viewsDictionary]];

    

    [self setupSliders];

    [self updateColors];

    [self setupTargetActions];

}

 

- (void)setupSliders {

    

    self.customView.trackWidthSlider.maximumValue = 100.0;

    self.customView.gaugeWidthSlider.maximumValue = 100.0;

    self.customView.valueSlider.value = self.customView.gauge.value;

    self.customView.trackWidthSlider.value = self.customView.gauge.trackWidth;

    self.customView.gaugeWidthSlider.value = self.customView.gauge.gaugeWidth;

    self.customView.valueSliderLabel.text = [self formattedStringForFloatValue:(self.customView.gauge.value * 100)];

    self.customView.trackWidthSliderLabel.text = [self formattedStringForFloatValue:self.customView.gauge.trackWidth];

    self.customView.gaugeWidthSliderLabel.text = [self formattedStringForFloatValue:self.customView.gauge.gaugeWidth];

    self.customView.valueSlider.continuous = NO;

    self.customView.trackWidthSlider.continuous = NO;

    self.customView.gaugeWidthSlider.continuous = NO;

}

 

- (void)updateColors {

    

    self.customView.valueColorIndicatorView.backgroundColor = self.customView.gauge.textColor;

    self.customView.trackColorIndicatorView.backgroundColor = self.customView.gauge.trackTintColor;

    self.customView.gaugeColorIndicatorView.backgroundColor = self.customView.gauge.gaugeTintColor;

}

 

- (void)setupTargetActions {

    

    UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(changeState:)];

    [self.customView.gauge addGestureRecognizer:tapGestureRecognizer];

    

    [self.customView.gaugeStyleSwitch addTarget:self action:@selector(changeGuageStyle:) forControlEvents:UIControlEventValueChanged];

    [self.customView.valueSlider addTarget:self action:@selector(valueSliderChangedValue:) forControlEvents:UIControlEventValueChanged];

    [self.customView.trackWidthSlider addTarget:self action:@selector(trackWidthSliderChangedValue:) forControlEvents:UIControlEventValueChanged];

    [self.customView.gaugeWidthSlider addTarget:self action:@selector(gaugeWidthSliderChangedValue:) forControlEvents:UIControlEventValueChanged];

    

    tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(changeValueColor:)];

    [self.customView.valueColorIndicatorView addGestureRecognizer:tapGestureRecognizer];

    tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(changeTrackColor:)];

    [self.customView.trackColorIndicatorView addGestureRecognizer:tapGestureRecognizer];

    tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(changeGaugeColor:)];

    [self.customView.gaugeColorIndicatorView addGestureRecognizer:tapGestureRecognizer];

}

 

#PRagma mark - Action Methods

 

- (void)changeState:(UITapGestureRecognizer *)tapGestureRecognizer {

    

    if (self.customView.gauge.state != CHCircleGaugeViewStateNA) {

        self.customView.gauge.state = CHCircleGaugeViewStateNA;

    } else {

        [self.customView.gauge setValue:self.customView.gauge.value animated:YES];

    }

}


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 修水县| 五寨县| 周口市| 雷波县| 龙江县| 嘉禾县| 正宁县| 赣榆县| 望城县| 兴安县| 凌云县| 红桥区| 凌云县| 方城县| 阿合奇县| 福泉市| 巴林左旗| 正安县| 衡水市| 伊金霍洛旗| 固阳县| 开远市| 舟曲县| 阿克陶县| 马公市| 泽普县| 巫溪县| 上栗县| 棋牌| 班玛县| 铜鼓县| 蓝田县| 错那县| 裕民县| 镇江市| 滦南县| 广灵县| 区。| 察隅县| 双峰县| 延吉市|