iOS 中的色轮或颜色选择器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7173031/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 21:14:27  来源:igfitidea点击:

Color wheel or color picker in iOS

iphoneobjective-ciosipadcolors

提问by user891268

How can I make a color wheel, color picker, or hue selector in iOS for use on the iPad.

如何在 iOS 中制作色轮、颜色选择器或色调选择器以在 iPad 上使用。

Here is an example picture of a color picker similar to what I want.

这是类似于我想要的颜色选择器的示例图片。

enter image description here

在此处输入图片说明

@All Thanks in advance.

@All 提前致谢。

采纳答案by Luke

This postcould help you out. One easy way to pick a color is to get the color of a pixel in an image you supply. This github projectalso has full source for a color picker.

这篇文章可以帮到你。选择颜色的一种简单方法是获取您提供的图像中像素的颜色。这个 github 项目也有一个颜色选择器的完整源代码。

回答by SAKrisT

My color picker, easy to integrate https://github.com/sakrist/VBColorPickerenter image description here

我的颜色选择器,易于集成https://github.com/sakrist/VBColorPicker在此处输入图片说明

回答by Tommie C.

Nothing wrong with the other answers. I am just sharing another color pickercreated using Swift.

其他答案没有错。我只是分享另一个使用 Swift 创建的颜色选择器

swift-colorwheel

快速色轮

回答by limon

I know this question's been already answered and accepted, but all of github projects that's been mentioned here looks like deprecated and obsolete. I've found RSColorPickerwhich is easy to use and has all the functionalities that i was looking for. Most importantly it's not obsolete.

我知道这个问题已经得到了回答和接受,但是这里提到的所有 github 项目看起来都已经过时了。我发现RSColorPicker易于使用并且具有我正在寻找的所有功能。最重要的是它并没有过时。

回答by jjxtra

I thought I would throw my color picker into the ring. I use it in my app, You Doodleand I spent a couple weeks making it and testing it in the app. It contains a sample project to show you how to get started with it and is open sourced under the MIT license. It supports any device (iOS 6+), any resolution and portrait and landscape. Favorites, recents, color by hue, color wheeland importing textures, as well as deleting and moving favorites to the front is supported.

我想我会把我的颜色选择器扔进戒指。我在我的应用程序You Doodle 中使用它,我花了几个星期制作它并在应用程序中测试它。它包含一个示例项目,向您展示如何开始使用它,并且在 MIT 许可下开源。它支持任何设备(iOS 6+)、任何分辨率以及纵向和横向。支持收藏夹、最近收藏、按色调着色色轮和导入纹理,以及删除收藏夹并将其移到前面。

I've tried to combine the good pieces of all the other color pickers and ensure that the MIT license allows a no hassle integration into any project.

我试图结合所有其他颜色选择器的优点,并确保 MIT 许可证允许轻松集成到任何项目中。

Github:https://github.com/jjxtra/DRColorPicker

Github:https : //github.com/jjxtra/DRColorPicker

Screenshots:

截图:

DRColorPicker iPhoneDRColorPicker iPadDRColorPicker iPhoneDRColorPicker iPadDRColorPicker iPhoneDRColorPicker iPad

DRColorPicker iPhoneDRColorPicker iPadDRColorPicker iPhoneDRColorPicker iPadDRColorPicker iPhoneDRColorPicker iPad

回答by Dave

Found another pretty simple article...with sample code here.

找到了另一篇非常简单的文章...这里有示例代码。

回答by Roman Filippov

I did create a sector of a color wheel in draw(_ rect: CGRect). See here.

我确实在 draw(_rect: CGRect) 中创建了一个色轮的扇区。看这里。

That my color wheel: sector of color wheel

那我的色轮: 色轮扇区

This view based on the next lines of code:

此视图基于以下代码行:

override func draw(_ rect: CGRect) {
    guard let context = UIGraphicsGetCurrentContext() else {
        return
    }

    // Choice width and x position of a rect where will be placed you picker
    for x in stride(from: bounds.midX - bounds.height, to: bounds.midX + bounds.height, by: elementSize) {

        // Choice height and y position of the rect
        for y in stride(from: 0, to: rect.height, by: elementSize) {

            // Select color for a point
            context.setFillColor(colorFor(x: x, y: y))

            // Select color for the point with elementSize which we declare and init as class property
            context.fill(CGRect(x: x, y: y, width: elementSize, height: elementSize))
        }
    }
}