몇 번 꺼도 소용없어요.
5857 단어 Swift
방법
다음 보기 컨트롤러를 만듭니다.
AsciiAlertController.swift
import UIKit
class AsciiAlertController: UIAlertController {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
for label in findLabels(in: view) {
label.textAlignment = .left
label.font = UIFont.monospacedDigitSystemFont(ofSize: label.font.pointSize, weight: .regular)
}
}
func findLabels(in view: UIView) -> [UILabel] {
return view.subviews.flatMap({ subview -> [UILabel] in
if let label = subview as? UILabel {
return [label] + findLabels(in: label)
} else {
return findLabels(in: subview)
}
})
}
}
다음과 같이 호출합니다ViewController.swift
func showAlert() {
let message = """
∧_∧ ババババ
( ・ω・)=つ≡つ
(っ ≡つ=つ
`/ )
(ノΠU
何回閉じても無駄ですよ?ww
m9(^Д^)プギャー!!
"""
let dialog = AsciiAlertController(title: nil, message: message, preferredStyle: .alert)
dialog.addAction(UIAlertAction(title: "閉じる", style: .default, handler: { _ in
self.showAlert()
}))
show(dialog, sender: nil)
}
방법을 강구하는 곳
컨디션
Reference
이 문제에 관하여(몇 번 꺼도 소용없어요.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/ottijp/items/004e88172a49bd7c7a1f텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)