1
如何突出顯示一個按鈕,使用textLabel按下圖像替換爲正常按鈕?當我按下這個按鈕Picture時,動作將被激活,但沒有按鈕本身的反饋。突出顯示按鈕按下它
import UIKit
import AVFoundation
class PlayMusicViewController: UIViewController {
var audioPlayer: AVAudioPlayer!
override func viewDidLoad() {
super.viewDidLoad()
var daten = NSBundle.mainBundle().pathForResource("Kool_Savas_Auge", ofType: "mp3")
var filePathUrl = NSURL.fileURLWithPath(daten!)
do{
audioPlayer = try AVAudioPlayer(contentsOfURL: filePathUrl, fileTypeHint: nil)
}
catch let err as NSError{
print(err.debugDescription);
}
}
@IBAction func PlayMusic(sender: UIButton) {
audioPlayer.play()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}
嗨 - 你問如何的目標,你會添加一個UIImageView到一個UIButton?除了你不希望圖像像UIButton那樣「點擊」?另外,你是在談論iOS還是OSX? – Sparky
使用相關代碼更新您的問題,以獲得目前爲止所做的一切。 – rmaddy
我插入代碼 –