[Translation] SwiftUI official tutorial (a)

Please complete Chinese tutorial and see github.com/WillieWangW...

SwiftUI Profile

SwiftUIA is any Applemodern fashion statement of the user interface platform. At an unprecedented rate, create a beautiful, dynamic applications.

Only need to describe a layout

To view content and layout of your statement any state, once the status is changed, SwiftUIautomatically updated rendering views.

List(landmarks) { landmark in
   HStack {
      Image(landmark.thumbnail)
      Text(landmark.name)
      Spacer()
      
      if landmark.isFavorite {
         Image(systemName: "star.fill")
            .foregroundColor(.yellow)
      }
   }
}
复制代码

Construction of reusable components

The combination of small, isolated view of the larger, more complex interface. In any as Applebetween application platform designed to share your custom views.

struct FeatureCard: View {
   var landmark: Landmark
   
   var body: some View {
      landmark.featureImage
         .resizable()
         .aspectRatio(3/2, contentMode: .fit)
         .overlay(TextOverlay(landmark))
   }
}
复制代码

Streamlining animation

Create smooth animation is as simple as calling a single method. SwiftUIIt will automatically calculate and transition animation when necessary.

VStack {
   Badge()
      .frame(width: 300, height: 300)
      .animation(.basic())
   Text(name)
      .font(.title)
      .animation(Animation.basic().delay(0.25))
}
复制代码

In Xcode live preview

No need to run the application, you can design, build and test the application interface. Interactive preview to test your controls and layout.

Reproduced in: https: //juejin.im/post/5cfa6f1e6fb9a07eb3096cd1

Guess you like

Origin blog.csdn.net/weixin_33738555/article/details/91430745