SwiftUI 线性仪表

问题描述

更新

我能够更接近我想要实现的目标。还需要工作。我尝试使用圆角矩形作为蒙版,但看起来不太好。任何建议将不胜感激。

enter image description here

SELECT * FROM (select table_1.id,table_1.fname,table_1.lname,table2.room,CASE
       WHEN id_rank = 1 THEN contact1
       WHEN id_rank = 2 THEN contact2
       WHEN id_rank = 3 THEN contact3
    END as contact

FROM 

(
select
    table_1.id,table_3.contact1,table3.contact2,table_3.contact3,dense_rank() over ( partition by table3.id order by table_1.id asc ) 
       as "id_order"
FROM
    table_3 left join 
    table_1 on table_3.cid = table_1.id
left join table_2
    on table_1.room = table_2.id

where 
    table_1.location = 1
and 
    table_1.room in (1,2,3,4,5,6,7,8,9,10,11)
) as sub_query

)
  as main_query

WHERE contact is NOT NULL;

年长

我正在尝试创建一个简单的仪表,例如 watchOS 中的线性仪表。我遇到的问题是找出覆盖当前值的正确方法。我想看到的结果如下。我相信有更好的方法

结果

enter image description here

我的看起来非常糟糕

enter image description here

GeometryReader { geometry in
    RoundedRectangle(cornerRadius: 7.5,style: .circular)
        .fill(LinearGradient(gradient: Gradient(colors: [Color.green,Color.yellow,Color.orange,Color.red,Color.purple]),startPoint: .bottom,endPoint: .top))
        .frame(width: geometry.size.width,height: geometry.size.height,alignment: .bottomLeading)
        .overlay(Color.black.opacity(0.35).cornerRadius(7.5))
    RoundedRectangle(cornerRadius: 7.5,alignment: .bottomLeading)
        .mask(
            vstack {
                Spacer()
                Rectangle()
                    // Adjust value 1 to needs
                    .frame(width: geometry.size.width,height:geometry.size.height * (CGFloat(1) / CGFloat(11)),alignment: .bottom)
            })
}
.frame(width: 15,height: .infinity)
.padding(.all,10)

解决方法

我已经解决了我的解决方案。我通过自定义 ProgressView 样式设法创建了相同的视图。

enter image description here