ios - SwiftUI: Scaling in Xcode is not the same as on my iPhone
问题描述
import SwiftUI
let coloredNav = UINavigationBarAppearance()
let colors = AppData.getData()
var navBarTitle = "Nav Bar"
var navIconSelected = 0
struct ContentView: View {
init() {
//UITabBar.appearance().isTranslucent = false
//UITabBar.appearance().barTintColor = .white
coloredNav.backgroundColor = .white
// UINavigationBar.appearance().titleTextAttributes = [.foregroundColor: UIColor(colors.gray)]
UINavigationBar.appearance().standardAppearance = coloredNav
//UINavigationBar.appearance().titleTextAttributes = [.font : UIFont(name: "Georgia-Bold", size: 20)!]
}
var body: some View {
TabView {
NavigationView
{
VStack
{
Text("Home")
}
.navigationBarTitle("Home", displayMode:.inline)
}.tabItem {
Image(systemName:"house")
}
.tag(ViewTag.feed)
NavigationView
{
VStack
{
Text("Messages")
}
.navigationBarTitle("Messages", displayMode:.inline)
}.tabItem {
Image(systemName:"text.bubble")
}
.tag(ViewTag.messages)
NavigationView
{
VStack
{
Text("Phone")
}
.navigationBarTitle("Phone", displayMode:.inline)
}.tabItem {
Image(systemName:"phone")
}
.tag(ViewTag.call)
NavigationView
{
VStack
{
Text("Notifications")
}
.navigationBarTitle("Notifications", displayMode:.inline)
}.tabItem {
Image(systemName:"bell")
}
.tag(ViewTag.notifications)
NavigationView
{
ScrollView{
VStack
{
ProfileView(data: ProfileData.getPreviewData())
//.padding([.top], 0)
}
}
.navigationBarTitle("Profile", displayMode:.inline)
}.tabItem {
Image(systemName:"person.crop.circle")
}
.tag(ViewTag.profile)
}
.accentColor(colors.mid)
//.accentColor(Color(red: 0.212, green: 0.275, blue: 0.282))
.navigationBarTitle(navBarTitle)
.navigationBarHidden(false)
.navigationBarTitleDisplayMode(.inline)
}
}
enum ViewTag {
case feed
case messages
case call
case notifications
case profile
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
This is my code ^ ^ ^
Basically, the sizing of the reviews widget is not the same on Xcode as it is when I run it on my phone. In Xcode I use the iPhone 11 simulator, and I also run the app on an iPhone 11.
Here is a comparison:
Here is the computer: https://i.stack.imgur.com/NYBuZ.png
Here is the phone: https://i.stack.imgur.com/8nmpJ.png
For this case specifically, it's not that big of a deal, but when dealing with more stuff, it really throws off the whole look. Any help is appreciated greatly. Thank you so much!
Also - if you are going to say it looks the same size, trust me, it's not. The same thing happens with text and shapes on a bigger scale, I just couldn't get a screenshot for that.
解决方案
推荐阅读
- elasticsearch - 如果日志中的文档时间字段早于文档中的当前时间字段,则 Logstash 忽略文档更新
- python - 为 python 脚本制作 Web 界面的最佳方法
- python - Cassandra:根据非主键删除记录 - Python
- angular - 如何在 GoDaddy 上托管 Angular-CLI 项目?
- node.js - 如何使用 socket.io 将 tcp 消息发送到远程服务器
- javascript - 如何相对于底层图像绝对定位形状元素?
- python - How to add numpy matrix as new columns for pandas dataframe?
- mysql - 使用 Node.js 搜索 PDF 文本
- mysql - using GROUP_CONCAT in MySQL Transaction
- javascript - Passing .NET Core Environment to React.JS app