简体   繁体   English

IOS - 添加颜色选择器子视图时使父视图变暗

[英]IOS - dim parent view when add a color picker subview

[Picker color view][1] [选择器颜色视图][1]

I would like to make a view (like the one in screenshot below).我想做一个视图(就像下面截图中的那个)。 When the picker view shows up, the screen behind is faded just like the photo. When the picker view shows up, the screen behind is faded just like the photo. Thank for your help!!感谢您的帮助!!

I believe it's not hard to achieve this.我相信实现这一目标并不难。

First, create a UIView called ColorPickerView and add some buttons with custom image to it(in your example, circles with different color).Then add the Cancel button so the user can remove(using removeFromSuperView) ColorPickerView by tapping it.首先,创建一个名为ColorPickerView的 UIView 并向其添加一些带有自定义图像的按钮(在您的示例中,具有不同颜色的圆圈)。然后添加Cancel按钮,以便用户可以通过点击它来删除(使用 removeFromSuperView) ColorPickerView Finally, add a UILabel to represent the title of ColorPickerView .最后,添加一个 UILabel 来表示ColorPickerView的标题。

When the ColorPickerView show up, you should add a view on your mainPageView(Screen behind ColorPickerView ).ColorPickerView出现时,您应该在 mainPageView( ColorPickerView后面的屏幕)上添加一个视图。 Let's call it blurView .我们称之为blurView Set the backgroundColor of blurView to black, alpha to 0.3(your choice).blurView的 backgroundColor 设置为黑色,将 alpha 设置为 0.3(您的选择)。 Similarly, when ColorPickerView is going to be removed, you should remove the blurView also.同样,当要删除ColorPickerView时,您也应该删除blurView

You can remove blurView in the action of Cancel button.您可以在Cancel按钮的操作中删除blurView

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM