CocoaPods 安裝

pod 'MaterialComponents'
pod install

Swift

import MaterialComponents.MaterialButtons
override func viewWillAppear(_ animated: Bool) {
    let raiseButton = MDCRaisedButton.init();
    raiseButton.frame = CGRect.init(x: 100, y: 100, width: 100, height: 100)
    raiseButton.setTitle("Raised Button", for: .normal)
    raiseButton.sizeToFit()
    raiseButton.addTarget(self, action: #selector(tapped), for: .touchUpInside)
    self.view.addSubview(raiseButton)
}
let textfieldFloating = MDCTextField()
textfieldFloating.frame = CGRect.init(x: 100, y: 200, width: 100, height: 100) self.view.addSubview(textfieldFloating)

Categorized in: