watchOS: Complications

Feb 7 2023 · Swift 5.6, watchOS 8.5, Xcode 13

Part 2: Tinted & Custom Complications

11. Build a SwiftUI View for a Complication

Episode complete

Play next episode

Next
About this episode
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 10. Tint SwiftUI Complications Next episode: 12. Refactor SwiftUI Views

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

For most complications, you’ll use the templates you learned about earlier in the course.

Showing an appointment

Open the CalendarComplication starter project.

EventView.swift

I already performed the pieces related to EventKit to save you some time.

HStack {

}
HStack {
  RoundedRectangle(cornerRadius: 3)
}
  RoundedRectangle(cornerRadius: 3)
    .frame(width: 5)
    .frame(width: 5)
    .foregroundColor(Color(event.calendar.cgColor))
private let formatter: DateIntervalFormatter = {

}
  let formatter = DateIntervalFormatter()

  formatter.dateStyle = .none
  formatter.timeStyle = .short
  return formatter
// 3
}()
// 1
VStack(alignment: .leading) { 

}
  Text(formatter.string(from: event.startDate, to: event.endDate))
    .font(.subheadline)
  Text(event.title)
    .font(.headline)
  if let location = event.location {
    Text(location)
      .font(.subheadline)
  }
}