SwiftUIでText中の文字の太さや色を変える
SwiftUIで画像を丸く切り取り枠を付ける方法です。 150×200サイズに画像をリサイズして表示させています。 アスペクト比が異なる場合ははみ出た箇所を切り取って表示しています。

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct ContentView: View { | |
var body: some View { | |
VStack { | |
Text("I") | |
.font(.system(size: 20).bold()) | |
+ Text(" ❤️ ") | |
.foregroundStyle(Color.red) | |
+ Text("Snorlax") | |
.foregroundStyle(Color.black) | |
.font(.system(size: 20).bold()) | |
+ Text("!\n") | |
+ Text("Snorlax ") | |
.foregroundStyle(Color.red) | |
.font(.system(size: 20).bold()) | |
+ Text("is most ") | |
.foregroundStyle(Color.blue) | |
.font(.system(size: 20).bold()) | |
+ Text("cute & cool& powerful .") | |
.foregroundStyle(Color.green) | |
.font(.system(size: 20).bold()) | |
+ Text("Pokemon.") | |
.foregroundStyle(Color.yellow) | |
.font(.system(size: 20).bold()) | |
} | |
} | |
} |