1

I'm trying to change the background image of a WKInterfaceButton in my storyboard when a tap occurs. Also, on calling the setBackgroundImage to change the image, appendValue(1) does not work.

class keyPadInterfaceController : WKInterfaceController{
    @IBOutlet weak var OneClicked: WKInterfaceButton!
        let whiteImage = UIImage(named:"keybutton1.png")
        let goldImage = UIImage(named:"keybutton2.png")

    @IBAction func OneTapped(sender:AnyObject) {
        OneClicked.setBackgroundImage(goldImage)
        appendValue(1) 
    }
}
4

1 回答 1

2

要访问图像,setBackgroundImage 您必须首先从用户 iPhone 传递它们

或者,您可以使用setBackgroundImageNamed. 因此,WatchKit 首先检查您的 WatchKit 应用程序包,然后是设备端缓存

OneClicked.setBackgroundImageNamed("keybutton2.png")
于 2015-05-19T23:22:31.220 回答