有朋友在使用標(biāo)尺的過程中發(fā)現(xiàn)了一些問題诺核,特此對(duì)標(biāo)尺升級(jí)了一下,有需要的朋友請(qǐng)自己去下載久信,文章底部有標(biāo)尺的樣式截圖
https://github.com/clarkIsMe/scrollRulerView
或者采用cocoapods 安裝
pod 'TTScrollRuler'
//安裝成功之后
#import <TTScrollRulerView.h>
使用方法介紹
/**
* 經(jīng)典標(biāo)尺 樣式
**/
TTScrollRulerView *rulerClassic = [[TTScrollRulerView alloc] initWithFrame:CGRectMake(50, 50+100*0, cy_ScreenW-100, 100)];
[self.view addSubview:rulerClassic];
rulerClassic.rulerDelegate = self;
//在執(zhí)行此方法前窖杀,可先設(shè)定參數(shù):最小值,最大值裙士,橫向入客,縱向等等 ------若不設(shè)定,則按照默認(rèn)值繪制
[rulerClassic classicRuler];
/**
* 自定義標(biāo)尺 樣式
**/
TTScrollRulerView *rulerCustom = [[TTScrollRulerView alloc] initWithFrame:CGRectMake(50, 50+100*1, cy_ScreenW-100, 100)];
[self.view addSubview:rulerCustom];
rulerCustom.rulerDelegate = self;
//在執(zhí)行此方法前腿椎,可先設(shè)定參數(shù):最小值桌硫,最大值,橫向酥诽,縱向等等 ------若不設(shè)定鞍泉,則按照默認(rèn)值繪制
[rulerCustom customRulerWithLineColor:customColorMake(0, 0, 0) NumColor:[UIColor redColor] scrollEnable:YES];
/**
* 橫向滾動(dòng),刻度位于上方
**/
TTScrollRulerView *rulerHUP = [[TTScrollRulerView alloc] initWithFrame:CGRectMake(50, 50+100*2, cy_ScreenW-100, 100)];
[self.view addSubview:rulerHUP];
rulerHUP.rulerDelegate = self;
//設(shè)置滾動(dòng)方向肮帐,默認(rèn)橫向滾動(dòng)
rulerHUP.rulerDirection = RulerDirectionHorizontal;
//設(shè)置刻度位置咖驮,默認(rèn)在上方
rulerHUP.rulerFace = RulerFace_up_left;
[rulerHUP classicRuler];
/**
* 橫向滾動(dòng),刻度位于下方
**/
TTScrollRulerView *rulerHDOWN = [[TTScrollRulerView alloc] initWithFrame:CGRectMake(50, 50+100*3, cy_ScreenW-100, 100)];
[self.view addSubview:rulerHDOWN];
rulerHDOWN.rulerDelegate = self;
//設(shè)置滾動(dòng)方向训枢,默認(rèn)橫向滾動(dòng)
rulerHDOWN.rulerDirection = RulerDirectionHorizontal;
//設(shè)置刻度位置托修,下方
rulerHDOWN.rulerFace = RulerFace_down_right;
[rulerHDOWN classicRuler];
/**
* 縱向滾動(dòng),刻度位于左邊
**/
TTScrollRulerView *rulerVUP = [[TTScrollRulerView alloc] initWithFrame:CGRectMake(50, 50+100*4, 100, 250)];
[self.view addSubview:rulerVUP];
rulerVUP.rulerDelegate = self;
//設(shè)置滾動(dòng)方向恒界,默認(rèn)橫向滾動(dòng)
rulerVUP.rulerDirection = RulerDirectionVertical;
//設(shè)置刻度位置睦刃,下方
rulerVUP.rulerFace = RulerFace_up_left;
[rulerVUP classicRuler];
/**
* 縱向滾動(dòng),刻度位于右邊
**/
TTScrollRulerView *rulerVDOWN = [[TTScrollRulerView alloc] initWithFrame:CGRectMake(50+100, 50+100*4, 100, 250)];
[self.view addSubview:rulerVDOWN];
rulerVDOWN.rulerDelegate = self;
//設(shè)置滾動(dòng)方向十酣,默認(rèn)橫向滾動(dòng)
rulerVDOWN.rulerDirection = RulerDirectionVertical;
//設(shè)置刻度位置涩拙,下方
rulerVDOWN.rulerFace = RulerFace_down_right;
[rulerVDOWN classicRuler];
/**
* 參數(shù)改變后际长,重新繪制標(biāo)尺
**/
rulerVDOWN.lockMin = 50;
[rulerVDOWN reDrawerRuler];
/**
* 讓標(biāo)尺滾動(dòng)到某一個(gè)數(shù)值
**/
[rulerVDOWN scrollToValue:50 animation:NO];
/**
* 自定義標(biāo)尺
* 注意事項(xiàng):
* 1、標(biāo)尺視圖的frame需要足夠標(biāo)尺顯示出來兴泥,自己摸索
* 2工育、最小值、最大值搓彻、單位刻度值如绸,最好一起設(shè)定,只設(shè)定部分會(huì)和默認(rèn)值產(chǎn)生沖突
* 3旭贬、默認(rèn)值的意思是標(biāo)尺創(chuàng)建之后怔接,刻度所在的位置,若不設(shè)定稀轨,會(huì)默認(rèn)在最小值的位置
* 4扼脐、自定義指針的frame是相對(duì)于標(biāo)尺視圖的
* 如果遇到其它問題,無法解決靶端,請(qǐng)聯(lián)系QQ:943051580
**/
TTScrollRulerView *rulerView = [[TTScrollRulerView alloc] initWithFrame:CGRectMake(50+100*2+50, 50+100*4, 150, 250)];
[self.view addSubview:rulerView];
rulerView.rulerDelegate = self;
//縱向滾動(dòng)
rulerView.rulerDirection = RulerDirectionVertical;
//最小值
rulerView.lockMin = 1000;
//最大值
rulerView.lockMax = 50000;
//一個(gè)刻度代表的數(shù)值
rulerView.unitValue = 100;
//默認(rèn)值
rulerView.lockDefault = 2000;
//不顯示刻度數(shù)值
rulerView.isShowRulerValue = YES;
//背景顏色
rulerView.rulerBackgroundColor = [UIColor whiteColor];
//自定義指針位置
rulerView.pointerFrame = CGRectMake(rulerView.bounds.size.width/2.0-cy_fit(80), cy_fit(65), cy_fit(80), cy_fit(1));
//自定義指針圖片
rulerView.pointerImage = nil; //可自定義
rulerView.pointerBackgroundColor = [UIColor blueColor];
[rulerView classicRuler];