我在应用程序底部弹出的这个小细节视图的底部插入了一个CAGradientLayer.正如你所见,我已经将 colored颜色 从白色设置为透明,但是出现了一种奇怪的灰色.有什么 idea 吗?

    // Set up detail view frame and gradient
    [self.detailView setFrame:CGRectMake(0, 568, 320, 55)];

    CAGradientLayer *layer = [CAGradientLayer layer];
    layer.frame = self.detailView.bounds;
    layer.colors = [NSArray arrayWithObjects:(id)[UIColor whiteColor].CGColor, (id)[UIColor clearColor].CGColor, nil];
    layer.startPoint = CGPointMake(1.0f, 0.7f);
    layer.endPoint = CGPointMake(1.0f, 0.0f);
    [self.detailView.layer insertSublayer:layer atIndex:0];

以下是有问题的观点:

Here is the problematic view

推荐答案

clearColor有一个Alpha为0的黑色通道,所以我不得不使用

[UIColor colorWithWhite:1 alpha:0]

而且它工作得很好.

Ios相关问答推荐

SwiftUI.从自定义视图修改器访问自定义视图子视图

SwiftUI拖动手势和内容拖动时的奇怪行为( skip /卡顿)

围绕对象旋转和移动相机不起作用Swift SceneKit

NSHashTable要求任何MyCustomProtocolAnyObject都是类类型

Xcode 15阻止我的应用程序运行:由于实时模式录制的高比率,丢失了1条日志(log)/路标消息?

RFID scanner 的蓝牙服务 UUID?

拔下设备后,DriverKit USB 驱动程序 (dext) 进程不会终止

无法在 CollectionView 中禁用部分弹跳 - 组合布局

在 SwiftUI 中放置全局 NavigationPath 的位置

如何根据条件快速将返回类型设为 LinearGradient 或 AngularGradient?

视图之间的 SwiftUI 过渡,没有过渡

clipShape swift的三元

@Environment 的存在会导致列表在滚动时不断重建其内容

Xcode 14 需要为 Pod Bundles Select 开发团队

UICollectionView - 动态单元格高度?

在原生和 phonegap 之间挣扎,简单的应用需求

从 NSUserDefaults 字典 iOS 中删除所有键

如何在ios中生成UUID

在 UITableViewController 中使用 UISearchDisplayController 时断言失败

UIView - 加载视图时如何获得通知?