日期:2014-05-16  浏览次数:20695 次

windows phone:动画

基于帧与基于时间

动画的执行速度可以是显示屏的视频硬件刷新率,也可以是时钟时间。因为视频显示屏刷新一次称为一帧,所以根据刷新频率的不同,动画可分为基于帧的动画和基于时间的动画。下面的示例可以看到这两种动画的差异:

xaml文件片段如下:

    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <TextBlock Grid.Row="0"
                       Text="Frame-Based"
                       FontSize="{StaticResource PhoneFontSizeLarge}"
                       HorizontalAlignment="Center"
                       VerticalAlignment="Center"
                       RenderTransformOrigin="0.5 0.5">
                <TextBlock.RenderTransform>
                    <RotateTransform x:Name="rotate1" />
                </TextBlock.RenderTransform>
            </TextBlock>

            <TextBlock Grid.Row="1"
                       Text="Time-Based"
                       FontSize="{StaticResource PhoneFontSizeLarge}"
                       HorizontalAlignment="Center"
                       VerticalAlignment="Center"
                       RenderTransformOrigin="0.5 0.5">
                <TextBlock.RenderTransform>
                    <RotateTransform x:Name="rotate2" />
                </TextBlock.RenderTransform>
            </TextBlock>