Ich habe eine TabelleView mit Menüoptionen. In diesen Menüoptionen habe ich Bilder und Labels.Bildfarbe ändern in tableView in Swift 3
Ich möchte, wenn ich in einer Option auf das Symbolbild klicke, ändern Sie die aktuelle Farbe in eine andere Farbe.
var menuNameArr : Array = [String]()
var iconImageNormal : Array = [UIImage]()
var iconImageSelected : Array = [UIImage]()
@IBOutlet weak var imgLogo: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
menuNameArr = ["Menu", "Map", "Favorites", "Orders", "Settings", "Help"]
iconImageNormal = [UIImage(named: "icon-coffee-cup-gray")!, UIImage(named: "icon-placeholder-gray")!,
UIImage(named: "icon-star-gray")!, UIImage(named: "icon-shopping-cart-gray")!,
UIImage(named: "icon-settings-gray")!, UIImage(named: "icon-help-gray")!]
iconImageSelected = [UIImage(named: "icon-coffee-cup-green")!, UIImage(named: "icon-placeholder-green")!,
UIImage(named: "icon-star-green")!, UIImage(named: "icon-shopping-cart-green")!,
UIImage(named: "icon-settings-green")!, UIImage(named: "icon-help-green")!]
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func numberOfSections(in tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return menuNameArr.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "MenuTableViewCell", for: indexPath) as! MenuTableViewCell
cell.imgIcon.image = iconImageNormal[indexPath.row]
cell.lblMenuName.text! = menuNameArr[indexPath.row]
cell.lblMenuName.textColor = UIColor(colorLiteralRed: 183.0/255.0, green: 183.0/255.0, blue: 183.0/255.0, alpha: 1)
return cell
}
Weiß jemand wie ich das mache?
Vielen Dank! Es funktionierte! –