UWP 动画系列之模仿网易云音乐动画
一、前言
最近在弄毕业设计(那时坑爹选了制作个UWP商店的APP),一个人弄得烦躁,在这里记录一些在做毕业设计时的学习过程。由于我的毕业设计是做一个音乐播放器,那么Windows商店上优秀的软件当然是网易云音乐了,为了不用自己去设计一些界面,所以山寨之路走起吧。
二、模仿网易云音乐动画之播放页面切换
直接观察网易云音乐的播放界面切换动图,可以看得出播放界面的变换中心是左小角,通过缩小和放大实现播放界面的切换,同时播放界面是覆盖了原界面上。

模仿这个动画用xaml很容易就可以实现出来,下面一步步实现。
1、首先准备播放面板和主界面,布局类似网易云界面,xaml如下:
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<SplitView x:Name="SplitView"
DisplayMode="CompactInline"
IsPaneOpen="{TemplateBinding IsLeftPaneContentOpen}"
CompactPaneLength="40"
OpenPaneLength="200">
<SplitView.Pane>
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid x:Name="HambegerGrid"
Margin="10,10"
Background="Transparent">
<TextBlock FontFamily="Segoe MDL2 Assets"
Text=""
FontSize="20"
Foreground="{TemplateBinding Foreground}"/>
</Grid>
<ContentPresenter x:Name="LeftPaneContentPresenter"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Grid.Row="1">
</ContentPresenter>
</Grid>
</SplitView.Pane>
<SplitView.Content>
<ContentPresenter x:Name="ContentPresenter">
<ContentPresenter.RenderTransform>
<TranslateTransform x:Name="ContentPresenterTranslateTransform" />
</ContentPresenter.RenderTransform>
</ContentPresenter>
</SplitView.Content> </SplitView> <ContentPresenter x:Name="SplitViewSwapContentPresenter"
Visibility="Collapsed"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
RenderTransformOrigin="0,1">
<ContentPresenter.RenderTransform>
<CompositeTransform ScaleX="0" ScaleY="0"/>
</ContentPresenter.RenderTransform>
</ContentPresenter>
<ContentPresenter x:Name="FooterContentPresenter"
Grid.Row="1"
VerticalAlignment="Bottom"
HorizontalAlignment="Stretch" />
注:SplitView是主页面,SplitViewSwapContentPresenter是播放界面,FooterContentPresenter是底部播放面板
2、设置播放面板界面的变换中心为左下角,在xaml的SplitViewSwapContentPresenter上即可以设置,如下
RenderTransformOrigin="0,1"
3、制作播放面板界面放大缩小动画。
利用Blend设置这一步十分容易方便。生成的xaml代码如下,
<Storyboard x:Name="SplitViewSwapContentIn">
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="SplitViewSwapContentPresenter"
Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0"
Value="Visible" />
</ObjectAnimationUsingKeyFrames>
<DoubleAnimation Duration="0:0:0.4" To="1" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleX)" Storyboard.TargetName="SplitViewSwapContentPresenter" >
<DoubleAnimation.EasingFunction>
<QuadraticEase EasingMode="EaseIn"/>
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
<DoubleAnimation Duration="0:0:0.4" To="1" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleY)" Storyboard.TargetName="SplitViewSwapContentPresenter" >
<DoubleAnimation.EasingFunction>
<QuadraticEase EasingMode="EaseIn"/>
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
</Storyboard>
<Storyboard x:Name="SplitViewSwapContentOut">
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="SplitViewSwapContentPresenter"
Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0:0:0.4"
Value="Collapsed" />
</ObjectAnimationUsingKeyFrames>
<DoubleAnimation Duration="0:0:0.4" To="0" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleX)" Storyboard.TargetName="SplitViewSwapContentPresenter" >
<DoubleAnimation.EasingFunction>
<QuadraticEase EasingMode="EaseOut"/>
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
<DoubleAnimation Duration="0:0:0.4" To="0" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleY)" Storyboard.TargetName="SplitViewSwapContentPresenter" >
<DoubleAnimation.EasingFunction>
<QuadraticEase EasingMode="EaseOut"/>
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
</Storyboard>
SplitViewSwapContentIn是放大动画,在keytime=0时,使播放面板呈现,且在keytime=0.4s的时候,使SplitViewSwapContent的(UIElement.RenderTransform).(CompositeTransform.ScaleX)和
属性和(UIElement.RenderTransform).(CompositeTransform.ScaleY)属性值变为1,这样设置会使播放面板当动画触发后0.4s过程中面板从小点变换到原来大小。SplitViewSwapContentOut与上面类似。 4、触发动画
接下来的就是什么时刻触发动画的问题了,首先在后台代码获得动画_splitViewSwapContentIn和_splitViewSwapContentOut,然后控制两个动画即可以控制播放面板的呈现与否。
void ShowSwapContent()
{
_splitViewSwapContentIn.Begin();
} void HideSwapContent()
{
_splitViewSwapContentOut.Begin();
}
三、模仿网易云音乐动画之播放页面的旋转动画
首先准备一类似的圆,xaml如下
<Ellipse x:Name="ellipse"
Width="250"
Height="250"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Margin="75,45,75,45"
RenderTransformOrigin="0.5,0.5">
<Ellipse.RenderTransform>
<CompositeTransform/>
</Ellipse.RenderTransform>
<Ellipse.Fill>
<ImageBrush ImageSource="{x:Bind CurrentTrack.PictureUrl, Mode=OneWay}" Stretch="Fill"/>
</Ellipse.Fill>
</Ellipse>
然后设置动画,xaml如下:
<Storyboard x:Name="EllStoryboard" RepeatBehavior="Forever">
<DoubleAnimation Duration="0:0:20" To="360" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.Rotation)" Storyboard.TargetName="ellipse" d:IsOptimized="True"/>
</Storyboard>
当然需要注意的时候当播放界面没有呈现的时候需要暂停或停止旋转动画的运转,不然会造成性能负担。
四、最后的实现的效果
最后山寨的效果就是这样了,虽然还有很多缺陷,但不要嫌弃我的毕业设计...
UWP 动画系列之模仿网易云音乐动画的更多相关文章
- NeteaseCloudWebApp模仿网易云音乐的vue自己从开源代码中学习到的
github地址: https://github.com/javaSwing/NeteaseCloudWebApp 1.Vue.prototype.$http = Axios // 类似于vue-re ...
- UWP仿网易云音乐之1-TitleBar
首先,创建一个UWP的项目.我使用的是Visual Studio 2017 社区版. 如图,我们将项目命名为UWP-Music. 现在我们先标题栏的配色调整与网易云音乐一致. 我们先分析一下标题栏,默 ...
- WPF仿网易云音乐系列(一、左侧菜单栏:Expander+RadioButton)
1.简介 上一篇咱们说到,网易云音乐的左侧菜单栏可以通过Expander+RadioButton来实现,具体如何实现,咱们下面开始干: 首先来一张网易云音乐PC版原图(个人觉得PC版比UWP版左侧菜单 ...
- WPF仿网易云音乐系列(序)
1.简介 由于之前做了一个播放器,苦于不懂界面设计,只得去借鉴借鉴一些成功的作品,网易云音乐就甚合朕心,哈哈,最后做出来的效果如下: 本系列文章就来和大家讨论以下,如何用WPF去仿制一个网易云音乐来: ...
- 由 UWP 版网易云音乐闪退引发的博文
今天,不知怎么的.网易云音乐出现了一打开就闪退的情况.百度了好些时候未果,就直接 Windows + i 打开 Windows 设置 > 应用 在应用和功能列表中找到网易云音乐,在展开的 高级选 ...
- Android版网易云音乐唱片机唱片磁盘旋转及唱片机机械臂动画关键代码实现思路
Android版网易云音乐唱片机唱片磁盘旋转及唱片机机械臂动画关键代码实现思路 先看一看我的代码运行结果. 代码运行起来初始化状态: 点击开始按钮,唱片机的机械臂匀速接近唱片磁盘,同时唱片磁盘也 ...
- C# WPF 低仿网易云音乐(PC)Banner动画控件
原文:C# WPF 低仿网易云音乐(PC)Banner动画控件 由于技术有限没能做到一模一样的动画,只是粗略地做了一下.动画有点生硬,还有就是没做出网易云音乐的立体感.代码非常简单粗暴,而且我也写有很 ...
- C# WPF 仿网易云音乐(PC)Banner动画控件
在自定义用户控件内添加3个border(左.中.右,以下分别简称为:b1.b2.b3),对border进行缩放和移动动画.往右切换时b1放大平移到b2的位置,b2缩小平移到b3的位置,b3平移到b1的 ...
- 千万不要更新网易云音乐UWP!!!!!
网易云音乐UWP没了!!! 现在 Micrsoft Store 里面的是垃圾 Win32 转置版!!!! 万不可更新!!! 若已经更新,还有救回来的办法:下载 https://lanzous.com/ ...
随机推荐
- DuiLib 源码分析之CDuiString
duilib是一个比较常见的界面库,闲来无事看看别人写的代码,跟自己写的一比, 才看到了差距呀,感觉自己写的乱七八糟,keep moving CduiString是duilib提供的一个字符串类,功能 ...
- ximalaya
- Excel字符串连接
1.利用&连接. ="('"&A4&"','"&B4&"','"&C4&" ...
- iOS多线程
关于iOS多线程 概述 这篇文章中,我不会说多线程是什么.线程和进程的区别.多线程有什么用,当然我也不会说什么是串行.什么是并行等问题,这些我们应该都知道的. 在 iOS 中其实目前有 4 套多线程方 ...
- 不在折腾---hbase-0.96.2-hadoop2
首先安装好zookeeper集群 上传hbase安装包 解压 配置hbase集群,要修改3个文件 * 修改hbase-env.sh 设置JAVA_HOME: export JAVA_HOME=... ...
- angularjs不同页面间参数的传递
1.在路由中定义要接收的参数 .state('userDetails', { url: '/userDetails?phone', //以?为标识接收参数 templateUrl: 'assets/v ...
- css学习笔记 3
css选择符: 通配选择符:* 类选择符:.className 标签选择符 后代选择符:例:p strong ,选择的是p标签内的所有strong标签. 子选择符:> ,只选择父标签内的直接子标 ...
- css3新增选择器
1. img[alt]:匹配页面标签中任意一个含有alt属性的标签 2. 匹配开头:img[alt^="film"] 匹配包含内容:img[alt*="film" ...
- kaggle数据挖掘竞赛初步--Titanic<原始数据分析&缺失值处理>
Titanic是kaggle上的一道just for fun的题,没有奖金,但是数据整洁,拿来练手最好不过啦. 这道题给的数据是泰坦尼克号上的乘客的信息,预测乘客是否幸存.这是个二元分类的机器学习问题 ...
- YY前端课程-自习
1. 默认的浏览器字体 100% = 1em =1rem =16px =12pt em继承父元素,rem只继承html根元素 2. text-align水平对齐影响一个元素中文本的水平对齐方式,控 ...

