Skip to content

Commit 6065208

Browse files
Update README.md
1 parent 4b38646 commit 6065208

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

README.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,27 +41,33 @@
4141

4242
官方教程:
4343

44-
```
45-
...
44+
```Swift
45+
.
46+
.
47+
.
4648
struct MapView: UIViewRepresentable {
4749
func makeUIView(context: Context) -> MKMapView {
4850
MKMapView(frame: .zero)
4951
}
5052
}
51-
...
53+
.
54+
.
55+
.
5256
```
5357

5458
这里的 `UIViewRepresentable` 是一个协议,它的声明中包含一个 `associatedtype` :
5559

56-
```
60+
```Swift
5761
/// The type of `UIView` to be presented.
5862
associatedtype UIViewType : UIView
5963
```
6064

6165
在开发中,给此 `associatedtype` 赋值后 Xcode 对方法的签名补全会有变化,最终写作:
6266

63-
```
64-
...
67+
```Swift
68+
.
69+
.
70+
.
6571
struct MapView : UIViewRepresentable {
6672

6773
typealias UIViewType = MKMapView
@@ -70,7 +76,9 @@ struct MapView : UIViewRepresentable {
7076
return MKMapView(frame: .zero)
7177
}
7278
}
73-
...
79+
.
80+
.
81+
.
7482
```
7583

7684
如此修改不再一一列举,只需记得**此类修改不会改变原教程的构建结果**即可,不必过于纠结。

0 commit comments

Comments
 (0)