按钮 交互

Microinteractions have become increasingly important in a world with a dizzying number of digital platforms and an ocean of content. While microinteractions used to be considered an interesting resource in the early days of digital design, in today’s hypercompetitive digital space they have become a crucial element in the overall user experience.

在拥有令人眼花number乱的数字平台和无数内容的世界中,微交互变得越来越重要。 尽管微交互在数字设计的早期曾被视为一种有趣的资源,但在当今竞争激烈的数字空间中,微交互已成为整个用户体验中的关键要素。

Basically, a microinteraction is a particular moment of a user’s interaction with a product in order to complete a specific task. For example, when someone presses a “Like” button (whatever it looks like) and sees that their action produced feedback — the number has changed, the color of the button has changed or it has become inactive, the text on the button reported that the action was done and so on — this is a case of microinteraction.

基本上,微交互是用户与产品进行交互以完成特定任务的特定时刻。 例如,当某人按下“赞”按钮(无论其外观如何)并看到他们的动作产生了反馈-数字已更改,按钮的颜色已更改或已变为无效状态时,该按钮上的文字会报告操作已完成,依此类推-这是微交互的情况。

The idea here is to present a menu button with 4 horizontal lines, and, when the user taps on the button, it animates into an ‘x’ shape, to represent the option of closing the menu.

这里的想法是呈现一个带有4条水平线的菜单按钮,当用户点击该按钮时,它会动画化为“ x”形,以表示关闭菜单的选项。

I began with an empty project, enabling SwiftUI. Then I created a file with two views, like this:

我从一个空项目开始,启用了SwiftUI。 然后,我创建了一个具有两个视图的文件,如下所示:

I defined a fixed frame for it, and for my purposes it can be a square shaped button. There’s a state property isAnimating, that the animations will respond to.

我为此定义了一个固定框架,出于我的目的,它可以是方形按钮。 有一个状态属性isAnimating ,动画将对其进行响应。

For the button body the action is simply to toggle the isAnimating property, and its label closure calls the createMenu method. Let's take a look at it.

对于按钮主体,操作仅是切换isAnimating属性,其标签闭合调用createMenu方法。 让我们来看看它。

There’s a lot going on here, but I’ll break it down. First, the method returns a type eraser view AnyView, and contains two properties, the count, which is the number of rows for the button, and the configuration of the menu.

这里有很多事情,但我会分解。 首先,该方法返回一个类型的橡皮擦视图AnyView ,并包含两个属性: count (按钮的行数)和菜单的配置。

In menu the geometry reader is used, so that we can access the width and height we have available, and, therefore, calculate the properties we need. So, 4 views are grouped, and we calculate availableHeight, spacing, height and width.

menu ,使用了几何图形读取器,以便我们可以访问可用的宽度和高度,从而计算所需的属性。 因此,对4个视图进行了分组,然后我们计算了availableHeightspacingheightwidth

Then, the rectangles are created with the height and width, and we can finally configure them. Each rectangle is overlapping the other ones, so we’ll use the offset modifier and multiply the index by the available height. This way they get positioned correctly along the y axis.

然后,使用高度和宽度创建矩形,最后我们可以对其进行配置。 每个矩形都与其他矩形重叠,因此我们将使用offset修饰符并将索引乘以可用高度。 这样,它们就可以正确地沿y轴定位。

Then I configured the animations, which are custom modifiers. I’ll get to them in a second. Finally I used the animation modifier, with a small delay and the easeInOut option, and return the menu.

然后,我配置了动画,它们是自定义修改器。 一会儿,我会去找他们。 最后,我使用了animation修改器( easeInOut延迟)和easeInOut选项,然后返回菜单。

配置动画 (Configuring the Animations)

The MiddleMenuRect is a custom modifier that handles the second and third rectangles (index '1' and '2'). Both of them need to rotate, on opposite directions.

MiddleMenuRect是一个自定义修饰符,用于处理第二个和第三个矩形(索引“ 1”和“ 2”)。 它们都需要沿相反的方向旋转。

Here’s how the code look like:

代码如下所示:

In the body function, two modifiers are being called: rotate and offset. That's because when the rect is rotated there's a slight difference in position, so they need to me adjusted in order to form the 'x'.

在body函数中,调用了两个修饰符: rotateoffset 。 这是因为当旋转rect时,位置略有不同,因此需要对它们进行调整以形成“ x”。

The modifiers return a value based on a condition of being the middle indexes and the isAnimating boolean.

修饰符基于成为中间索引和isAnimating布尔值的条件返回值。

For the MarginMenuRect the setup is very similar, but this time, the first and last indexes are placed as conditions and the modifiers opacity and offset are applied. While the rectangles are moved through the 'x' axis in different directions, the opacity is reduced, giving the idea that they were 'removed'. Check out the code:

对于MarginMenuRect的设置非常相似,但是这次,第一个和最后一个索引作为条件放置,并且应用了修饰符opacityoffset 。 当矩形沿“ x”轴沿不同方向移动时,不透明度降低了,从而产生了“已删除”的想法。 签出代码:

For better readability, the MiddleMenuRect and the MarginMenuRect view modifiers were added to an extension:

为了提高可读性,在扩展中添加了MiddleMenuRectMarginMenuRect视图修饰符:

That’s it! We have a nice menu button, that when tapped turns into an ‘x’. Here’s how it looks in action:

而已! 我们有一个不错的菜单按钮,当您点击它时,它会变成一个“ x”。 实际效果如下:

Nice, isn’t it?

很好,不是吗?

Utilising microinteractions can enrich usability. The features of an app attract a user to the product, but the details more then often make a huge difference. This was an example of how a microinteraction can be implemented in SwiftUI and give a nice touch to your apps.

利用微交互可以丰富可用性。 应用程序的功能吸引了用户使用该产品,但是更多的细节通常会带来巨大的不同。 这是一个示例,说明了如何在SwiftUI中实现微交互并为您的应用程序提供良好的体验。

Developing it was fun, and it was pleasant to see the animation in place. If you want to see the full code, here’s the gist. Thanks for reading!

开发它很有趣,并且很高兴看到动画到位。 如果您想查看完整的代码,这是要点 。 谢谢阅读!

Originally published at https://vinileal.com on April 11, 2020.

最初于 2020年4月11日 发布在 https://vinileal.com 上。

翻译自: https://uxdesign.cc/microinteractions-in-swiftui-menu-button-animation-5d60f802fe5d

按钮 交互


http://www.taodudu.cc/news/show-894070.html

相关文章:

  • 选择控件— UI组件系列
  • 用户体验改善案例_改善用户体验研究的5种习惯
  • 巴克莱对冲_“巴克莱的财政预算案”:使金钱管理对心理健康有效—用户体验案例研究
  • c# 设计原则需要学习吗_向最好的学习:产品设计原则
  • 外国经典儿童读物合集pdf_帮助父母在线购买儿童读物–用户体验案例研究
  • 同态加法_同态的Spotify
  • 粉红噪音_粉红的常绿力量
  • v-charts加载动画_加载动画-用户体验写作练习
  • svg动画制作_制作第一个SVG动画
  • 平面设计和网页设计的规则_从平面设计到用户界面:这是您应该知道的最重要的规则
  • 设计类的五个原则_内容设计的5个原则
  • 永不示弱_永不过时的网页设计:今天和2000年的在线投资组合
  • 谈谈对java中分层的理解_让我们谈谈网页设计中的卡片设计
  • qt ui指针和本类对象_您需要了解的有关UI设计的形状和对象的所有信息
  • skysat重访周期_重访小恶梦
  • 魔兽怀旧网站模块下载_一个人的网站重新设计和怀旧
  • 汉堡菜单_汉堡菜单-可访问性和用户体验设计原则的挑战?
  • c# ui 滚动 分页_UI备忘单:分页,无限滚动和“加载更多”按钮
  • 16位调色板和32位调色板_使调色板可访问
  • ux设计_为企业UX设计更好的数据表
  • figma下载_Figma中的高级图像处理
  • 指针和指针的指针_网络上的iPad指针
  • 书籍排版学习心得_为什么排版是您可以学习的最佳技能
  • 线框图用什么软件_为什么要在线框中着色?
  • qq空间网页设计_网页设计中负空间的有效利用
  • matlab中的:的优先级_内容早期设计:内容优先
  • 脑裂问题解决方案_从解决方案到问题
  • 调查谋杀案以换取Obra Dinn
  • ux设计中的各种地图_移动应用程序设计中的常见UX错误
  • 工业仪器仪表 界面设计_如何设计时尚的仪表板界面

按钮 交互_SwiftUI中的微交互—菜单按钮动画相关推荐

  1. 移动应用交互设计_了解移动应用程序设计中的微交互

    可用性是移动UI设计的关键组成部分之一. 伟大的可用性通常涉及微交互 ,这些微 交互是来自界面的小响应和行为,指示应该如何使用UI. 这些微交互定义行为,鼓励互动并帮助用户可视化界面应如何工作. 数字 ...

  2. python 菜单按钮打开新窗口_Python Tkinter Menubutton菜单按钮

    Menubutton小部件可以定义为始终向用户显示的下拉菜单.它用于为用户提供选择应用程序中存在的适当选择的选项. Menubutton用于在python应用程序中实现各种类型的菜单.菜单与Menub ...

  3. B2C网站设计中微交互研究

    摘要:微交互作为引导电子商务网站设计发展的新的理论原则,受到国外交互设计师的广泛推崇,但在国内却并未被熟知.本文通过分析国内电子商务发展现状,详细阐释了微交互的理论方法与设计原则.深入探讨微交互理论在 ...

  4. dev项目属性按钮是灰色_如何当按钮处于各种交互状态时具有不同样式的按钮?...

    Axure RP 9 for Mac是一款交互式原型设计神器,使用axure rp9以最佳的方式展示您的作品,优化现代浏览器并为现代工作流程设计.同时确保您的解决方案正确完整地构建.在本篇文章中,我们 ...

  5. UI设计技巧|交互设计中七大常见定律

    交互设计之父阿兰·库珀说过,"除非有更好的选择,否则就遵从标准",各行各业都有自己的行业标准,那么你知道在交互设计中常用到的七大定律都有哪些吗?       1. Fitts' L ...

  6. 创建声音流时出错_如何设计微交互创建出色用户体验方案

    ♝点击上方"交互设计学堂"关注我们,送电子书 很多人把微交互简单的理解为做个动效,实质上,我们通常见到的那些动效只是微交互构成中的一部分,属于反馈层面的视觉表达. 微交互既不是一个 ...

  7. react 交互_如何在React中建立动画微交互

    react 交互 Microinteractions guide a user through your application. They reinforce your user experienc ...

  8. python作业.创建两个文本框,一个按钮。第 1 个文本框绑定任意键事件,敲击键盘任意可显示字符,在交互窗口中显示该字符;第 2 个文本框绑定<a>键事件,敲击键盘 a 字符,在交互窗口中显示 10

    """ 创建两个文本框,一个按钮. 第 1 个文本框绑定任意键事件,敲击键盘任意可显示字符,在交互窗口中显示该字符: 第 2 个文本框绑定<a>键事件,敲击键 ...

  9. 创建两个文本框,一个按钮。第 1 个文本框绑定任意键事件,敲击键盘任意可显示字符,在交互窗口中显示该字符;

    创建两个文本框,一个按钮.第 1 个文本框绑定任意键事件,敲击键盘任意可显示字符,在交互窗口中显示该字符:第 2 个文本框绑定键事件,敲击键盘 a 字符,在交互窗口中显示 10 个'a'字符:按钮绑定 ...

最新文章

  1. 互联网金融产品做第三方支付平台托管需要注意什么?
  2. 有效运维的 on-call 机制
  3. [react] 举例说明在react中怎么使用样式
  4. Android ANR视角InputDispatcher
  5. 从入门到入土:nmap出击:使用nmap扫描某台靶机,给出并解读靶机环境的配置情况
  6. ViewPager里面ImageView图片切换出现bug
  7. 一键快速生成视频字幕的免费工具
  8. 公众号html5页面代码,微信公众号网页H5跳转微信小程序
  9. html超链接打开共享文件夹,访问共享文件夹的方法
  10. JMX MBean class xxx does not implement DynamicMBean, and neither follows the Standard MBean conventi
  11. U盘不能分区,不能格式化,解决方案
  12. 知识图谱构建技术简介
  13. 日期相关(类与方法)
  14. High Availability for the HDFS Namenode
  15. MATLAB将灰度图转换为彩色图像源码实战
  16. “21天好习惯“ 第十六期 — 16之黑马面面移动端布局(二)
  17. 异常:Handling ClientRegistrationException error: No client with requested id: null
  18. 电气设备常用文字符号新旧对照表
  19. 信号与系统_系统频率响应
  20. 世博版新君威提车作业

热门文章

  1. xp下添加linux启动,如何在windows xp系统下安装linux???
  2. oppo售后解锁恢复工具.zip_OPPO手机4个不为人知的小技巧,全知道的竟然不到1%,令人唏嘘...
  3. mysqlbinlog恢复误删数据
  4. C++函数中返回引用和返回值的区别
  5. Linux命令(七)Linux用户管理和修改文件权限
  6. luogu4267 TamingtheHerd (dp)
  7. Vue提供操作DOM的方法
  8. C++ const的使用
  9. html5 canvas 笔记五(合成与裁剪)
  10. 用计算器计算“异或CRC”