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. UIView和子视图 - 不透明度
- 2. 整体SVG不透明度/透明度
- 3. SVG线性渐变填充不透明度梯度
- 4. 不透明度
- 5. UIView背景图像透明度问题
- 6. ccDrawLine不透明度?
- 7. Dat.gui不透明度
- 8. 与不透明度
- 9. .DrawImage不透明度?
- 10. CSS过渡:不透明度不透明。 。
- 11. 不透明度使div更不透明
- 12. 使用CSS变量与rgba的梯度透明度
- 13. 具有多个梯度的SVG透明度
- 14. 更改不透明度时重绘窗口不透明度
- 15. Div 70%不透明度,含有100%不透明度的图像
- 16. 带有不透明度梯度的虚线下划线链接样式
- 17. 段落中的不透明度变化改变了文本的不透明度和背景不透明度
- 18. 我需要不透明度(透明度)的IMG与CSS ie8
- 19. Firefox不透明度(透明度)渐变 - 淡出图像
- 20. 不透明度的文本透明度CSS
- 21. C#控制台不透明度/透明度
- 22. 图像的不透明度/透明度左至反之亦然
- 23. UILabel透明度
- 24. NSImage透明度
- 25. NSImage +透明度?
- 26. wmode透明度?
- 27. PNG透明度
- 28. 与透明度
- 29. LWJGL透明度
- 30. 与透明度
只需按照这篇文章的方向,你会算出它在30分钟内最多: http://stackoverflow.com/questions/4977947/cagradientlayer-and-scrollviewtexturedbackgroundcolor/4978450#4978450 – greenhouse