swiftuiカテゴリー記事の一覧です
import SwiftUI
struct ContentView: View {
let pi = 3.141519 // 円周率
var body: some View {
VStack {
Text("円周率:\(pi, specifier: "%.2f")")
//.foregroundColor(.blue)// 埋め込み変数piの整形
.font(.system(size: 50, weight: .black, design: .default))
.foregroundColor(.green)
Text(" ultraLight").font(.largeTitle).fontWeight(.ultraLight)
.kerning(5)
Text("エリア 200 x 200 の中に文章を中央寄りで表示します。よろしくお願いいたします。")
.frame(width: 200, height: 200, alignment: .leading)
.multilineTextAlignment(.leading)
Divider()
Text("SwiftUIで") +
Text("一部の文字").foregroundColor(.red).fontWeight(.bold) +
Text("だけを装飾する。")
}
// .font(.custom("Times-Roman", size: 50))
// .font(.title)
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
import SwiftUI
struct ContentView: View {
@State var selectedTag = 1
var body: some View {
TabView(selection: $selectedTag) {
HomeTabView().tag(1)
WeatherTabView().tag(2)
NewsTabView().tag(3)
NewsTabView2().tag(4)
NewsTabView3().tag(5)
}
.tabViewStyle(PageTabViewStyle())
.ignoresSafeArea()
}
}
struct HomeTabView: View {
var body: some View {
VStack {
Image(systemName: "music.note.house")
.scaleEffect(x: 3.0, y: 3.0)
.frame(width: 100, height: 100)
Text("HOME").font(.system(size: 20))
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color(red: 0.5, green: 0.9, blue: 0.9))
.ignoresSafeArea()
}
}
struct WeatherTabView: View {
var body: some View {
VStack {
Image(systemName: "cloud.sun")
.scaleEffect(x: 3.0, y: 3.0)
.frame(width: 100, height: 100)
Text("お天気ページ").font(.system(size: 20))
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color(red: 1.0, green: 0.9, blue: 1.0))
.ignoresSafeArea()
}
}
struct NewsTabView: View {
var body: some View {
VStack {
Image(systemName: "newspaper")
.scaleEffect(x: 3.0, y: 3.0)
.frame(width: 100, height: 100)
Text("ニュースと解説").font(.system(size: 20))
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color(red: 0.9, green: 0.9, blue: 0.8))
.ignoresSafeArea()
}
}
struct NewsTabView2: View {
var body: some View {
VStack {
Image(systemName: "ant.circle.fill")
.scaleEffect(x: 3.0, y: 3.0)
.frame(width: 100, height: 100)
Text("ニュースと解説2").font(.system(size: 20))
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color(red: 0.9, green: 0.4, blue: 0.8))
.ignoresSafeArea()
}
}
struct NewsTabView3: View {
var body: some View {
VStack {
Image(systemName: "ladybug.fill")
.scaleEffect(x: 3.0, y: 3.0)
.frame(width: 100, height: 100)
Text("ニュースと解説3").font(.system(size: 20))
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color(red: 0.3, green: 0.4, blue: 0.8))
.ignoresSafeArea()
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
HomeTabView()
WeatherTabView()
NewsTabView()
}
}