我正在尝试制作类似这样的东西:
我不确定如何像这个人在 tom 和 bottom 工具栏上所做的那样半透明地镜像图像。
我将专辑封面保存在 UIImage
中....我可以只选择它的顶部并在顶部工具栏上翻转它并在底部工具栏上翻转底部吗?请记住,我需要在两个单独的工具栏上使用它,这些可以在 UIToolbar
上完成吗?我如何获得半透明的外观?
最佳答案
这些只是 UIImageViews 沿 x 轴翻转,并在其上绘制了渐变。 看看代码示例。您可能需要改变颜色并调整框架、开始和停止颜色...
#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];
关于iphone - 在 UIToolbar 上镜像局部图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18495348/