0
A
回答
0
alpha通道(即PNG)保存您的背景图像和做任何图形应用程式使用褪色。
然后,把它作为你的UIView的第一个孩子是一个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;
}
}
使用这个代码来设置
相关问题
- 1. 梯度底层不透明
- 2. three.js所不透明度梯度
- 3. WebKit的梯度和透明度
- 4. UIView z-index透明度
- 5. 透明GIF不显示透明度在背景与梯度在CSS中
- 6. UIView和子视图 - 不透明度
- 7. JButton的不透明度/半透明度?
- 8. 整体SVG不透明度/透明度
- 9. SVG线性渐变填充不透明度梯度
- 10. iOS:梯度半透明图像覆盖
- 11. CSS梯度,透明颜色IE?
- 12. 不透明度
- 13. 具有UIView透明度的GPUImage视频
- 14. UIView背景图像透明度问题
- 15. 与不透明度
- 16. 不透明度与
- 17. .DrawImage不透明度?
- 18. ccDrawLine不透明度?
- 19. SDL_Texture不透明度
- 20. Dat.gui不透明度
- 21. CSS过渡:不透明度不透明。 。
- 22. GMSMarker不透明度不透明动画
- 23. 不透明度使div更不透明
- 24. 具有多个梯度的SVG透明度
- 25. 使用CSS变量与rgba的梯度透明度
- 26. 更改不透明度时重绘窗口不透明度
- 27. c#winform不透明度70%,但面板内不透明度100%
- 28. Div 70%不透明度,含有100%不透明度的图像
- 29. 按钮不透明/透明度
- 30. 带有不透明度梯度的虚线下划线链接样式
只需按照这篇文章的方向,你会算出它在30分钟内最多: http://stackoverflow.com/questions/4977947/cagradientlayer-and-scrollviewtexturedbackgroundcolor/4978450#4978450 – greenhouse