聊天气泡

screenshotscreenshot

struct SingleChatBubble: PreviewProvider {
  static var previews: some View {
    Text("Stanford Video Steve Jobs’ 2005 Stanford Commencement Address I am honored to be with you today at your commencement from one of the finest universities in the world.")
      .fixedSize(horizontal: false, vertical: true)
      .chatBubble(
        direction: .leadingTop,
        cornerRadius: 17,
        color: .blue.opacity(0.5)
      )
  }
}
struct ShapePreview: PreviewProvider {
  static var previews: some View {
    ChatBubble(cornerRadius: 17)
      .frame(width: 300, height: 100)
      .foregroundColor(.cyan)
  }
}
struct RawChatBubble: PreviewProvider {
  static var previews: some View {
    Text("Sample Text.")
      .fixedSize(horizontal: false, vertical: true)
      .padding()
      .background {
        ChatBubble(cornerRadius: 17)
          .rotateChatBubble(position: .trailingBottom)
          .foregroundColor(.red.opacity(0.5))
      }
  }
}

参考资料

https://qiita.com/yuppejp/items/92429a0fc8440f9da487