在swiftui中创建策展的颜色选择器

Color pickers are used frequently in both iOS and Mac apps to differentiate folders/lists/items in Apple’s own app’s like Shortcuts and Reminders and many indie app’s offer similar functionality.

拾色器在iOS和Mac应用程序中经常使用,以区分Apple自己的应用程序(如快捷方式和提醒)中的文件夹/列表/项目,许多独立应用程序提供类似的功能。

With SwiftUI 2 Apple added the ColorPicker control and you think great, one quick line of code and I have a color picker, but this isn’t constrained, users can pick any color imaginable, great for paint apps, not so great where we are trying to maintain a style to our app and deal with overlaid text or graphics.

借助SwiftUI 2,Apple添加了ColorPicker控件,您认为很棒,只需一行代码,并且我有了一个颜色选择器,但这不受限制,用户可以选择任何可以想象的颜色,非常适合绘画应用程序,而不是我们想要的颜色尝试保持我们的应用程序的样式并处理覆盖的文本或图形。

Recently watching a non-tech family member discover they can customize their messaging app and the awful contrast choices made you really don’t want to let users have this much power. Even Apple don’t use the generic full palette picker in their apps, instead providing a curated palette to choose from, colors that they know will look good.

最近,一个非技术家庭成员发现他们可以自定义其消息传递应用程序,而糟糕的对比选择使您真的不想让用户拥有如此强大的功能。 甚至苹果公司也没有在他们的应用程序中使用通用的全调色板选择器,而是提供了精选的调色板供他们选择,他们知道这些颜色看起来不错。

When thinking of a solution to this I first started with throwing some RGB colored circles in a list and storing the value. That gets you part of the way but doesn’t allow for colors that adapt well between dark/light mode, high contrast or platform variations for iPhone, iPad, Mac, Apple Watch, TV and CarPlay which all have their own subtle requirements.

当想到解决方案时,我首先将一些RGB彩色圆圈放入列表中并存储值。 这使您成为问题的一部分,但不允许在暗/亮模式,高对比度或适用于iPhone,iPad,Mac,Apple Watch,TV和CarPlay的平台变化之间很好地适应颜色,这些都有自己的微妙要求。

In this article I’ll walk you through how I solved this and create a color picker, which I’ve called ColorSwatchView, that can cope with all these di

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值