WeatherLine iOS Widget 背景渐变不透明度

问题描述

我正在尝试使这个可编写脚本的 iOS 小部件的背景渐变更加透明,但我不知道如何并且我对 JavaScript 不熟悉。

https://github.com/italoboy/Full-Weatherline-Widget

这是我认为生成认背景的代码,但我不知道如何编辑它以使其不透明。

   let gradient = new LinearGradient()
   let gradientSettings = await setupGradient()
   gradient.colors = gradientSettings.color()
   gradient.locations = gradientSettings.position()  
  
   widget.backgroundGradient = gradient

而这应该是这里调用的对应函数

// Set up the gradient for the widget background.
async function setupGradient() {
  
  // Requirements: sunrise
  if (!sunData) { await setupSunrise() }

  let gradient = {
    dawn: {
      color() { return [new Color("142C52"),new Color("1B416F"),new Color("62668B")] },position() { return [0,0.5,1] },},sunrise: {
      color() { return [new Color("274875"),new Color("766f8d"),new Color("f0b35e")] },0.8,1.5] },midday: {
      color() { return [new Color("3a8cc1"),new Color("90c0df")] },noon: {
      color() { return [new Color("b2d0e1"),new Color("80B5DB"),new Color("3a8cc1")] },position() { return [-0.2,0.2,sunset: {
      color() { return [new Color("32327A"),new Color("662E55"),new Color("7C2F43")] },position() { return [0.1,0.9,1.2] },twilight: {
      color() { return [new Color("021033"),new Color("16296b"),new Color("414791")] },night: {
      color() { return [new Color("16296b"),new Color("021033"),new Color("113245")] },position() { return [-0.5,}

  const sunrise = sunData.sunrise
  const sunset = sunData.sunset

  // Use sunrise or sunset if we're within 30min of it.
  if (closeto(sunrise)<=15) { return gradient.sunrise }
  if (closeto(sunset)<=15) { return gradient.sunset }

  // In the 30min before/after,use dawn/twilight.
  if (closeto(sunrise)<=45 && currentDate.getTime() < sunrise) { return gradient.dawn }
  if (closeto(sunset)<=45 && currentDate.getTime() > sunset) { return gradient.twilight }

  // Otherwise,if it's night,return night.
  if (isNight(currentDate)) { return gradient.night }

  // If it's around noon,the sun is high in the sky.
  if (currentDate.getHours() == 12) { return gradient.noon }

  // Otherwise,return the "typical" theme.
  return gradient.midday
}

我希望这里有人可以帮助我。

我发现您可以向颜色函数添加一个参数,但即使我将其设置为 0% 不透明度,它也会显得更暗。

color() { return [new Color("142C52",0),new Color("1B416F",new Color("62668B",0)] },

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)