-2
A
回答
1
看看GitHub。你会发现gazillion颜色选择器在那里。这是第一个,我发现搜索时:
https://github.com/RSully/RSColorPicker
如果你是编程新手,你应该或许与内置的UI组件坚持。您可以使用两个UIButton来让用户在“红色”和“黑色”之间选择,并直接从按钮操作中设置文本颜色。
我认为一个完整的颜色选择器是您的第一个应用程序的大项目。
一个简单的实现可以简单地创建一个循环遍历可能的颜色的颜色井。
的下面ColorPickerView
是UIView
子类,它示出了这一点。
#import "ColorPickerView.h"
@implementation ColorPickerView
- (void)drawRect:(CGRect)rect {
// Create a grid of n*n wells each with a seperate color --
const int numberOfWells = 20;
const int totalWells = numberOfWells * numberOfWells;
// Figure out the size of each well --
const CGSize size = self.bounds.size;
const CGFloat boxHeight = floorf(size.height/numberOfWells);
const CGFloat boxWidth = floorf(size.width/numberOfWells);
CGContextRef context = UIGraphicsGetCurrentContext();
// Loop through all the wells --
for(int y = 0; y < numberOfWells; y++) {
for(int x = 0; x < numberOfWells; x++) {
int wellNumber = x + numberOfWells * y;
// Assign each well a color --
UIColor *boxColor = [self colorForWell:wellNumber ofTotal:totalWells];
[boxColor setFill];
CGRect box = CGRectMake(x*boxWidth, y*boxHeight, boxWidth, boxHeight);
CGContextAddRect(context, box);
CGContextFillRect(context, box);
}
}
}
-(UIColor*) colorForWell:(int) well ofTotal:(int) wells {
CGFloat red = (CGFloat) well/wells;
CGFloat green = well % (wells/3)/(CGFloat) (wells/3);
CGFloat blue = well % (wells/9)/(CGFloat) (wells/9);
return [UIColor colorWithRed:red green:green blue:blue alpha:1.0];
}
@end
让用户点击颜色并从触摸位置推断颜色。
-4
教你如何制作颜色选择器是不可能的。你应该学习Objective C,并且可能会看到一些现有的开源项目,这些项目是你想学习如何制作你自己的(如果你不想使用和编辑现有的)... 看看这些Color Pickers
相关问题
- 1. 如何在OS X中创建自定义颜色选择器
- 2. 如何创建颜色选择器轮滑块?
- 3. 如何创建颜色选择器对话框?
- 4. 颜色选择器
- 5. 如何在量角器中从颜色选择器窗口中选择颜色
- 6. 如何使用GWT颜色选择器
- 7. 如何使用prestashop颜色选择器
- 8. 我如何制作颜色选择器,选择三种不同的颜色?
- 9. 如何从kendo颜色选择器中为无颜色选择空值?
- 10. 如何实现颜色选择器而不是静态颜色
- 11. 如何将颜色选择器用于画布笔触颜色?
- 12. 颜色选择器选择的颜色显示
- 13. 颜色选择器OS-X选择错误的颜色
- 14. 颜色选择器,每个颜色选择发送事件
- 15. 如何在2d颜色选择器中创建一个返回2色之间颜色的函数?
- 16. iPhone颜色选择器
- 17. WP7颜色选择器
- 18. javascript颜色选择器
- 19. 颜色选择器在android?
- 20. 基于颜色选择器
- 21. 颜色选择器崩溃
- 22. flex 4.5.1颜色选择器
- 23. jQuery Mobile颜色选择器
- 24. Zen cart颜色选择器
- 25. 颜色选择器代码
- 26. 安装颜色选择器
- 27. Silverlight颜色选择器
- 28. 颜色选择器按钮
- 29. Eclipse RCP颜色选择器
- 30. Dynamics AX颜色选择器
谢谢你,你帮了我很多! – Yarondani