모든 도움에 감사드립니다 :)! iboutlet 컬렉션을 사용하여 고정시키고 viewDidLoad에 속성을 추가하십시오.UIButton에 속성을 추가하는 방법은 무엇입니까?
layer.shadowColor
또는 layer.shadowRadius
과 같은 키보드 키에 속성을 추가하려고합니다. 나는 오류
'Value of type '(UIButton)' ->() has no member 'layer'
이 어떻게 해결하기 위해
있어?이 내 코드 keyboardViewController.swift
수입 UIKit
클래스 KeyboardViewController : UIInputViewController { var에 newKeyboardView : UIView의!
@IBAction func keyPressed(sender: UIButton) {
}
@IBOutlet var nextKeyboardButton: UIButton!
override func updateViewConstraints() {
super.updateViewConstraints()
// Add custom view sizing constraints here
}
override func viewDidLoad() {
super.viewDidLoad()
loadInterface()
}
func loadInterface() {
// load the nib file
let keyboardNib = UINib(nibName: "newKeyboard", bundle: nil)
// instantiate the view
newKeyboardView = keyboardNib.instantiateWithOwner(self, options: nil)[0] as! UIView
// add the interface to the main view
view.addSubview(newKeyboardView)
// copy the background color
view.backgroundColor = newKeyboardView.backgroundColor
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated
}
override func textWillChange(textInput: UITextInput?) {
// The app is about to change the document's contents. Perform any preparation here.
}
override func textDidChange(textInput: UITextInput?) {
// The app has just changed the document's contents, the document context has been updated.
var textColor: UIColor
let proxy = self.textDocumentProxy
if proxy.keyboardAppearance == UIKeyboardAppearance.Dark {
textColor = UIColor.whiteColor()
} else {
textColor = UIColor.blackColor()
}
self.nextKeyboardButton.setTitleColor(textColor, forState: .Normal)
}
} 당신이 아니라 인수로 버튼을 받아들이는 폐쇄로가 아닌 버튼에 "속성을 추가"하려는처럼
과 같이 Swift로 iOS 개발에 대한 소개 과정을 따르는 것이 좋습니다. 코드를 표시 할 수 있습니까? – good4pc
@IBAction func keyPressed (발신자 : UIButton) { } 버튼을 추가하고 단추에 그림자를 추가하고 싶습니다. like with layer.shadowColor –
keyPressed (보낸 사람 : UIButton) 안에 그림자를 추가하는 코드를 작성합니다. 예를 들어 테두리 색상 추가를위한 코드를 추가했습니다. sender.layer.borderColor = UIColor.redColor(). CGColor sender.layer .borderWidth = 2.0 도움이 되길 바랍니다. – good4pc