如何使用 SWIFT 图像制作弹出窗口

How to make a popup window with an image SWIFT(如何使用 SWIFT 图像制作弹出窗口)
本文介绍了如何使用 SWIFT 图像制作弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何制作类似于此示例的弹出窗口:

I was wondering how to make a popup window similar to this example:

原始窗口充满了按钮,当被选中时会拉出我想要使用的图像.

The origin window is full of buttons that when is selected will then pull up the image I desire to use.

推荐答案

我会简单地创建一个可重用的 UIView 组件以及作为子视图所需的一切,例如 UIImageView 对于您的图像,右上角的 UILabelUIButton.这是展示它的过程:

I would simply create a reusable UIView component and everything you need as a subview, such as a UIImageView for your image, a UILabel or a UIButton in the top right. Here is the process to show it:

  1. 创建一个占满全屏的 UIView,使其变黑,并且可能是 0.5 alpha.
  2. 创建另一个 UIView 作为您的主要弹出视图,使其比前一个视图略小,但确保这两个视图都是父子视图的子视图.
  3. 将所需元素作为子视图添加到弹出视图中,如果您打算经常使用它,我什至建议创建一个 UIView 子类.
  4. 要显示弹出窗口,请确保将两个视图设置为 hidden = true 创建时,以便选择按钮时,可以将它们设置为 hidden = false
  5. 如果您希望它们具有动画效果,只需使用 alpha = 0.0 启动它们,然后使用 UIView 的 animateWithDuration 之类的东西,并将弹出视图设置为 alpha = 1.0
  1. Create a UIView that takes up the full screen, make it black, and maybe 0.5 alpha.
  2. Create another UIView which is your primary pop-up view, make it slightly smaller than the previous view, but make sure both of these views are subviews of the parent subview.
  3. Add the desired elements on to the pop-up view as subviews, I would even suggest creating a UIView subclass if you plan to use this a lot.
  4. To present the pop-up, make sure both views are set to hidden = true when created and so that when a button is selected, you can set them to hidden = false
  5. If you would like them to be animated, simply start them off with alpha = 0.0 and use something like UIView's animateWithDuration and set the pop-up view to alpha = 1.0

您可以更改很多小细节以满足您的需求,但这是实现目标的基本结构.

There is a lot of little details you can change to cater to your needs, but this is the basic structure on how to accomplish your goal.

查看 UIView 动画方法 这里.

Check out UIView animation methods here.

这篇关于如何使用 SWIFT 图像制作弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Why local notification is not firing for UNCalendarNotificationTrigger(为什么没有为UNCalendarNotificationTrigger触发本地通知)
iOS VoiceOver functionality changes with Bundle Identifier(IOS画外音功能随捆绑包标识符而变化)
tabbar middle tab out of tabbar corner(选项卡栏中间的选项卡角外)
Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
Dropbox Files.download does not start when number of files in folder is gt; 1000(当文件夹中的文件数为1000时,Dropbox Files.Download不会启动)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)