【问题标题】:Change storyboard or scenes on storyboard dynamically动态更改情节提要或情节提要上的场景
【发布时间】:2012-03-02 12:51:52
【问题描述】:

我想用 XCode 4.2 为 iPhone 编写一个应用程序。我使用标签栏来切换这个应用程序的功能。 我需要“情况”:一个“情况”是登录标签栏,第二个“情况”是登录标签栏。所以我想到了两个想法:要么我使用两个故事板并动态使用故事板,要么我只使用一个故事板并使用两个场景(登录和登录)并动态分配视图控制器。但我不知道我该如何编程这个.. 你是什​​么意思我必须做什么?我该怎么做?

感谢您的回答:)

【问题讨论】:

    标签: xcode ios5 xcode-storyboard


    【解决方案1】:

    请试试这个。希望对你有帮助。

    <Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="Trainning.animation"
    x:Name="Window"
    Title="animation"
    Width="640" Height="480">
    <Window.Resources>
        <Storyboard x:Key="one_in_all">
            <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="btn_animation_1">
                <EasingColorKeyFrame KeyTime="0" Value="#FFF0F0EA"/>
                <EasingColorKeyFrame KeyTime="0:0:0.2" Value="#FF038529"/>
                <EasingColorKeyFrame KeyTime="0:0:0.4" Value="#FFF0F0EA"/>
            </ColorAnimationUsingKeyFrames>
        </Storyboard>
    </Window.Resources>
    
    <Grid x:Name="LayoutRoot">
        <Button x:Name="btn_animation_1" Content="Animation1" HorizontalAlignment="Left" Height="54" Margin="187,133,0,0" VerticalAlignment="Top" Width="64" Click="btn_animation_1_Click" />
        <Button x:Name="btn_animation_2" Content="Animation2" Height="54" Margin="310,133,258,0" VerticalAlignment="Top" Click="btn_animation_2_Click" />
    </Grid>
    

    在代码后面

    using System.Windows.Media.Animation;
    
    public partial class animation : Window
    {
        string Name;
        public animation()
        {
            this.InitializeComponent();
    
            // Insert code required on object creation below this point.
        }
    
        private void btn_animation_1_Click(object sender, RoutedEventArgs e)
        {
            Button button = (Button)sender;
            Name = button.Name;
            Animation_In_All();
        }
    
        public void Animation_In_All()
        {
            Storyboard SB = (Storyboard)(FindResource("one_in_all"));
            Storyboard.SetTargetName(SB.Children[0], Name);           
            SB.Begin();
        }
    
        private void btn_animation_2_Click(object sender, RoutedEventArgs e)
        {
            Button button = (Button)sender;
            Name = button.Name;
            Animation_In_All();
        }
    }
    

    【讨论】:

    • 这与 iOS 故事板无关。
    猜你喜欢
    • 2012-02-03
    • 1970-01-01
    • 2014-08-01
    • 1970-01-01
    • 2018-07-01
    • 2014-05-05
    • 1970-01-01
    • 2014-09-07
    • 1970-01-01
    相关资源
    最近更新 更多