Pods Demo – CircularSliderDemo

Pods Demo – CircularSliderDemo

名稱 CircularSlider
適用版本 iOS7
原始碼 GitHub
授權 MIT

說明

CircularSlider 有三種顯示的方式提供,第一種是純單一數值顯示方式,第二種採用階段性索引顯示,最後一種是時間表示方式,直接整個範例下載後就會有這三種的展示方式。

CircularSlider 可以用手勢調整數值,就像範例擷圖滑鼠指標一樣的手勢,如果怕在調整過程中手勢不好調整,還可以利用上、下箭頭調整更細的細節。經由宣告的初始化方式來決定你要用的類型,並使用initWithFrame來決定Slider的顯示位置,之後再將整個View加入主要 的View。

上圖中可以用箭頭調整顯示的值。

展示

類型1

//-----------start-----------
#define COMPONENTRECT CGRectMake(45, 185, DK_SLIDER_SIZE-90, DK_SLIDER_SIZE-90)
- (void)viewDidLoad
{
    [super viewDidLoad];
    simpleCSlider = [[DKCircularSlider alloc] initWithFrame:COMPONENTRECT
                                                   usingMax:99
                                                   usingMin:1
                                           withContentImage:[UIImage imageNamed:@"sensitivity"]
                                                  withTitle:@"Sensitivity" withTarget:self usingSelector:@selector(sliderChange:)];
    [[self view] addSubview:simpleCSlider];
    [simpleCSlider movehandleToValue:10];
    [[self view] setBackgroundColor:[UIColor grayColor]];
}
-(void)sliderChange:(DKCircularSlider *)sender
{
    NSLog(@"Value Changed (%@)",[sender getTextValue]);
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
//------------end------------

類型2

//-----------start-----------
#define COMPONENTRECT CGRectMake(45, 185, DK_SLIDER_SIZE-90, DK_SLIDER_SIZE-90)
- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    guidedCSlider = [[DKCircularSlider alloc] initWithFrame:COMPONENTRECT
                                               withElements:@[@"Monday",@"Tuesday",@"Wednesday",@"Thursday",@"Friday",@"Saturday",@"Sunday"]
                                           withContentImage:[UIImage imageNamed:@"pawn.png"]
                                                  withTitle:@"Days"
                                                 withTarget:self usingSelector:@selector(sliderChange:)];
    [[self view] addSubview:guidedCSlider];
    [guidedCSlider movehandleToValue:1];
    [[self view] setBackgroundColor:[UIColor grayColor]];
}
-(void)sliderChange:(DKCircularSlider *)sender
{
    NSLog(@"Value Changed (%@)",[sender getTextValue]);
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
//------------end------------

類型3

//-----------start-----------
#define COMPONENTRECT CGRectMake(45, 185, DK_SLIDER_SIZE-90, DK_SLIDER_SIZE-90)
- (void)viewDidLoad
{
    [super viewDidLoad];
    timeCSlider = [[DKCircularSlider alloc] initWithFrame:COMPONENTRECT
                                                 usingMax:60*60
                                                 usingMin:0
                                   withRepresantationMode:DKCircularSliderRepresantationModeTime
                                         withContentImage:[UIImage imageNamed:@"pawn.png"]
                                                withTitle:@"time" withTarget:self usingSelector:@selector(sliderChange:)];
    [[self view] addSubview:timeCSlider];
    [timeCSlider movehandleToValue:1];
    [[self view] setBackgroundColor:[UIColor grayColor]];

}
-(void)sliderChange:(DKCircularSlider *)sender
{
    NSLog(@"Value Changed (%@)",[sender getTextValue]);
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
//------------end------------