我正在尝试通过创建图层并将其作为子图层添加到导航栏来更改导航栏的背景.但是,这只会影响导航栏.

我不想影响整个屏幕的顶部.代码包括:
let navBarLayer = StyleUtils.createGradientLayerWithColors(color: StyleUtils.Colors.SKY_BLUE, frame: (self.navigationController?.navigationBar.bounds)!)
self.navigationController?.navigationBar.layer.addSublayer(navBarLayer)
Run Code Online (Sandbox Code Playgroud)
所述createGradientLayerWithColors函数返回给定的帧中的CAGradientLayer.
我错过了什么?先感谢您.
编辑:
我试过纳撒尼尔的回答,但得到了这个:
值得一提的是,这也是一个TableView.
解:
我发现这个问题帮助我解决了这个问题.
最终正确的代码是:
func setNavBarColor() {
let navBar = self.navigationController?.navigationBar
//Make navigation bar transparent
navBar?.setBackgroundImage(UIImage(), for: .default)
navBar?.shadowImage = UIImage()
navBar?.isTranslucent = true
//Create View behind navigation bar and add gradient
let behindView = UIView(frame: CGRect(x: 0, y:0, width: UIApplication.shared.statusBarFrame.width, height: UIApplication.shared.statusBarFrame.height + (navBar?.frame.height)!))
let layerTop = StyleUtils.createGradientLayerWithColors(color: StyleUtils.Colors.SKY_BLUE, frame: behindView.bounds)
behindView.layer.insertSublayer(layerTop, at: 0)
self.navigationController?.view.insertSubview(behindView, belowSubview: navBar!)
}
Run Code Online (Sandbox Code Playgroud) 我无法理解Spark如何与存储交互.
我想创建一个Spark集群,从RocksDB数据库(或任何其他键值存储)中获取数据.但是,此时,我能做的最好的事情是将整个数据集从数据库中提取到每个集群节点的内存中(例如,到地图中)并从该对象构建RDD.
我只需要获取必要的数据(如Spark与HDFS一样)?我已经阅读了有关Hadoop输入格式和记录阅读器的内容,但我并没有完全理解我应该实现的内容.
我知道这是一个广泛的问题,但我真的很感激帮助我开始.先感谢您.
我正在玩Rust一点点,然后卡住了.我有以下功能:
fn addOne(h: (i32, i32, i32)){
let mut (x, y, z) = h;
(x+1, y+1, z+1)
}
Run Code Online (Sandbox Code Playgroud)
这给我在编译时出现以下错误:
example.rs:2:10: 2:11 error: expected identifier, found `(`
example.rs:2 let mut (x, y, z) = h;
Run Code Online (Sandbox Code Playgroud)
绑定有问题吗?对不起,如果这是一个简单的问题.
我有一个函数,其目的是接收一个由空格分隔的数字数组,一次一个数字,将它们分配给结构的变量,如下所示:
typedef struct coo {
int x;
int y;
} Coord;
typedef struct exer {
Coord coords[1000];
} exercise;
int coordinates(char *sent){
char * pal;
int k=0;
pal = strtok (sent," ");
while (pal != NULL)
{
exercise.coords[k].x=*pal;
pal = strtok (NULL," ");
exercise.coords[k].y=*pal;
pal = strtok (NULL," ");
k++;
}
return 1;
}
Run Code Online (Sandbox Code Playgroud)
问题是稍后打印的坐标与发送中给出的坐标不同.
如果我输入坐标1 2 3 4 5 6,它将给出坐标49 50 51 52 53.
先感谢您.
我对这样的函数有问题:
数据城市=城市{汽车::字符串,重量::整数,颜色::字符串}
- 我有一个“城市”列表,我的函数必须制作一个元组列表,每个元组都是(汽车,“权重之和”),因此,如果汽车相等,则权重必须是添加,做这样的事情:
main> [(Porche,180),(Ferrari,400),(Opel,340)]
Run Code Online (Sandbox Code Playgroud)
汽车不能在输出列表中重复,因为必须添加它们的高度。
我正在考虑做一些事情,比如列出所有汽车类型,然后过滤权重并添加它们,制作一个列表,但我无法让它工作。