我想尝试做类似的事情:
我不确定如何像这个人在汤姆和底部工具栏上做的那样半透明地镜像图像。
我将相册艺术保存在UIImage
....我可以只选择它的顶部并将其翻转到顶部工具栏上并翻转底部工具栏的底部吗?请记住,我需要在两个单独的工具栏上使用它,这些可以在UIToolbar
上完成吗?我怎样才能看到半透明的外观?
答案 0 :(得分:2)
这些只是沿着x轴翻转的UIImageViews,并在其上绘制了一个渐变。 看看代码示例。您可能需要改变颜色并调整框架,启动和停止颜色......
#import <QuartzCore/CAGradientLayer.h>
#import <QuartzCore/CALayer.h>
UIImageView *imgView = [[UIImageView alloc] initWithImage: coverImage];
//flip the view
imgView.transform = CGAffineTransformScale(self.imgView.transform, 1, -1);
CGRect frame = imgView.frame;
frame.size.height = 50.0; //or any other value
imgView.frame = frame;
self.imgView.contentMode = UIViewContentModeBottom;
self.imgView.layer.masksToBounds = YES;
//set the gradient
CAGradientLayer *layer = [CAGradientLayer layer];
layer.frame = self.imgView.bounds;
UIColor *startCol = [UIColor colorWithRed: 1.0 green: 1.0 blue: 1.0 alpha: 0.5];
UIColor *endCol = [UIColor colorWithRed: 1.0 green: 1.0 blue: 1.0 alpha: 1];
layer.colors = [NSArray arrayWithObjects: (id)startCol.CGColor, (id)endCol.CGColor, nil];
layer.startPoint = CGPointMake(0.5, 0);
layer.endPoint = CGPointMake(0.5, 1);
[self.imgView.layer addSublayer: layer];