iOS源碼下載:實(shí)現(xiàn)自定義畫圖功能
作者:佚名
實(shí)現(xiàn)了可自定義的畫圖功能,可以動(dòng)態(tài)選擇圖筆的顏色,線條粗細(xì)等。
支持平臺(tái):iOS
運(yùn)行環(huán)境:iOS
開發(fā)語言:Object-c
開發(fā)工具:Xcode
源碼大?。?66.12KB
源碼下載地址:http://down.51cto.com/data/1975550
源碼簡(jiǎn)介
實(shí)現(xiàn)了可自定義的畫圖功能,可以動(dòng)態(tài)選擇圖筆的顏色,線條粗細(xì)等。
源碼運(yùn)行截圖
效果圖
源碼片段
- - (id)initWithFrame:(CGRect)frame afterToolColor:(ToolColorBlock)toolcolor
- {
- _toolColorBlock = toolcolor;
- self = [super initWithFrame:frame];
- if (self) {
- self.backgroundColor = [UIColor lightGrayColor];
- _colorArray = [NSArray array];
- NSArray *array = @[[UIColor darkGrayColor],
- [UIColor redColor],
- [UIColor greenColor],
- [UIColor blueColor],
- [UIColor yellowColor],
- [UIColor orangeColor],
- [UIColor purpleColor],
- [UIColor brownColor],
- [UIColor blackColor]];
- _colorArray = array;
- [self creatColorButtons:array];
- }
- return self;
- }
- - (void)creatColorButtons:(NSArray *)array
- {
- NSInteger count = array.count;
- CGFloat buttonW = (self.bounds.size.width - (array.count+1)*kButtonSpace)/count;
- CGFloat buttonH = self.bounds.size.height;
- for (NSInteger i = 0; i<array.count; i++)="" {="" uicolor="" *color="array[i];" uibutton="" *button="[UIButton" buttonwithtype:uibuttontypecustom];="" button.tag="i;" [button="" addtarget:self="" action:@selector(tagbutton:)="" forcontrolevents:uicontroleventtouchupinside];="" cgfloat="" buttonx="kButtonSpace" +="" i="" *="" (buttonw="" +kbuttonspace);="" button.frame="CGRectMake(buttonX," 5,="" buttonw,="" buttonh-10);="" setbackgroundcolor:color];="" [self="" addsubview:button];="" }="" -="" (void)tagbutton:(uibutton="" *)button="" [uiview="" animatewithduration:0.5f="" animations:^{="" self.frame="CGRectMake(0," -self.bounds.size.height,="" 320,="" 44);="" }];="" _toolcolorblock(_colorarray[button.tag]);="" }<="" pre="">
- </array.count;>
責(zé)任編輯:閆佳明
來源:
網(wǎng)絡(luò)整理