https://github.com/innei/uikit-learning
https://github.com/innei/uikit-learning
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/innei/uikit-learning
- Owner: Innei
- Created: 2021-01-30T07:25:56.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-22T23:40:02.000Z (about 3 years ago)
- Last Synced: 2025-02-04T10:56:43.868Z (over 1 year ago)
- Language: Swift
- Size: 1.44 MB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Project-2
以下内容我随便写写
初始的 UIViewController 可以直接 Embed in UINavigationController
UIView 之间可以 Control + Drag 的方式在各个 View 之间设置相对位置,居中之类的
UIButton 通过连接的方式可以设置 onTap。直接 Drag 到连接函数。
多个 UIButton 连接同一个函数,可以通过设置每个 UIButton 的 tag 区分。
```swift
@IBAction func buttonTapped(_ sender: UIButton) {
var title: String
if sender.tag == correctAnswer {
title = "Correct"
score += 1
} else {
title = "Wrong"
score -= 1
}
}
```
UIAlartController 使用
```swift
let ac = UIAlertController(title: title, message: "Your score is \(score).", preferredStyle: .alert)
ac.addAction(UIAlertAction(title: "Continue", style: .default, handler: askQuestion))
present(ac, animated: true)
```
# Referrence