Для файла PageCell0 в моей библиотеке на github,
Я хочу использовать exetension в проекте, чтобы представить библиотеку и добавить UILabel (newLabel), используя addSubView.
Я написал это следующим образом в том месте, где я представил библиотеку, но я обеспокоен, потому что UILabel не отображается в симуляторе, даже если он построен.
Я ищу решение, но не знаю.
//Project file that introduced the library
import UIKit
import SlidingCellWithDrag0Framework
class ViewController: MainViewController {
var cell1: PageCell1?
var newLabel: UILabel = {
let nL = UILabel()
nL.textColor = UIColor.yellow
nL.text = "newLabel"
nL.translatesAutoresizingMaskIntoConstraints = false
return nL
}()
override func viewDidLoad() {
super.viewDidLoad()
cell1?.addSubview(newLabel)
newLabel.anchor(top: cell1?.topAnchor,
leading: cell1?.leadingAnchor,
bottom: nil,
trailing: cell1?.trailingAnchor,
padding: .init(top: 10, left: 20, bottom: 10, right: 30),
size: .init(width: 300,
height: 150))
}
}
: Изменить код
// AppDelegate
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
window = UIWindow(frame: UIScreen.main.bounds)
window?.makeKeyAndVisible()
let home = UINavigationController(rootViewController : ViewController())
window?.rootViewController = home
return true
}
}
```