2012-03-02 119 views
1

我想用XCode 4.2爲iPhone編程應用程序。我使用了一個tabbar來切換這個應用程序的功能。 我需要「情境」:在標籤欄中記錄一個「情境」,第二個「情境」是登錄標籤欄。因此,我有兩個想法:我要麼使用兩個故事板並動態使用故事板,要麼只使用一個故事板,並使用兩個場景(登錄和登錄)並動態分配視圖控制器。但我不知道如何編程這個.. 你是什麼意思我必須做什麼?我如何做到這一點?動態更改故事板上的故事板或場景

感謝回答:)

回答

0

請試試這個。我希望它能幫助你。

<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(); 
    } 
} 
+0

這無關與iOS故事板。 – David 2012-11-06 02:19:19