LoginSignup
9
9

More than 5 years have passed since last update.

UISliderのような円形のスライダーコントロールを作ってみた

Last updated at Posted at 2016-04-15

概要

iOSのUISliderは便利ですが、横に広くスペースを取る必要があるので、配置が難しくなります。
そこで、オーディオ機器のボリュームのような、円形のSliderを作ってみました。
Simulator Screen Shot 2016.04.15 16.22.34.png

使い方

サンプルコードのUICircleSliderフォルダごとプロジェクトにコピーしてください。
あとは、ほぼUISliderと同じです。

    // 画像
    circleSlider.image = [UIImage imageNamed:@"volume"];
    // 最小値
    circleSlider.minimumValue = 0;
    // 最大値
    circleSlider.maximumValue = 100;
    // 初期値
    circleSlider.value = 0;
    // 通知設定
    circleSlider.delegate = self;

値が変更された場合、delegateで通知するようにしています。

- (void)didChangeValue:(UICircleSlider *)sender
{
    [valueLabel setText:[NSString stringWithFormat:@"%.2f", sender.value]];
}

画像は自由に変更できます。(サンプルのように、上を向いている状態の画像を用いて下さい)

サンプルコード

本体と共にgithubからどうぞ。
UICircleSlider

9
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
9