2011-02-12 10 views
0

テクスチャ付き背景画像と不透明度勾配を持つUIIViewを使用できますか?すなわち、bg画像は、バックグラウンドコンテナビューに対して左から右にフェードインする必要があります。UIView不透明度勾配

おかげ

+0

を設定するには、このコードをそれを置きます: http://stackoverflow.com/questions/4977947/cagradientlayer-and-scrollviewtexturedbackgroundcolor/4978450#4978450 – greenhouse

答えて

0

は、アルファチャンネル(すなわち、PNG)を使用して背景画像を保存し、グラフィックスが使用するアプリ何でフェードを行います。その後

、UIImageView

0
- (void)viewDidLoad { 
    [super viewDidLoad]; 
    image1=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"Default.png"]]; 
    image1.frame=CGRectMake(0, 0, 320, 460); 
    image2=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"directoryPage.png"]]; 
    image2.frame=CGRectMake(0, 0, 320, 480); 
    [self.navigationController setNavigationBarHidden:YES]; 
} 

- (void)fade 
{ 
    image2.alpha = 0; 
    [self.view addSubview:image2]; 
    // The upper layer will transition from alpha 1 to 0s 
    [self.view addSubview:image1]; 
    BSheepAppDelegate *appD=(BSheepAppDelegate *)[[UIApplication sharedApplication]delegate]; 
    if(appD.flag==0){ 
     timer = [NSTimer scheduledTimerWithTimeInterval:.01 target:self selector:@selector(fadeTimerEvent) userInfo:nil repeats:YES]; 
     appD.flag=1; 
    } 
    else if (appD.flag==1) { 
    [self.view addSubview:image2]; 
    image2.alpha=1; 
    } 
} 

// Rate of transition for alpha values 
#define FADE_IN_RATE  1.0/100.0 
#define FADE_OUT_RATE 2.0/200.0 
- (void)fadeTimerEvent 
{ 
    if (image2.alpha >= 1) 
    { 
     // At this point, image2 is now visible 
     [timer invalidate]; 
     timer = nil; 

    } 
    else 
    { 
     // Fade lower layer in (increase alpha) 
     image2.alpha += FADE_IN_RATE; 
     // Fade upper layer out (decrease alpha) 
     image1.alpha -= FADE_OUT_RATE; 
    } 
} 

使用など、あなたのUIViewの最初の子としてちょうどこの記事の指示に従ってください、あなたは30分、最大でそれを把握します

関連する問題