I have the UIButton that I create, like this
let btn = UIButton()
view.addSubview(btn)
btn.setImage(UIImage(systemName: "star"), for: .normal)
btn.translatesAutoresizingMaskIntoConstraints = false
btn.frame = CGRect(x: 30, y: 30, width: 150, height: 150)
btn.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 35).isActive = true
btn.rightAnchor.constraint(equalTo: btnDelete.leftAnchor, constant: 0).isActive = true
btn.heightAnchor.constraint(equalToConstant: 44).isActive = true
btn.widthAnchor.constraint(equalToConstant: 44).isActive = true
the problem is that I see the star icon button, but I can't find a way to make it bigger and change the color of the star itself, currently it is blue, but I need it white.
CodePudding user response:
For make it bigger use below code to fill width and height u giving in btn.frame
:
btn.contentHorizontalAlignment = .fill
btn.contentVerticalAlignment = .fill
For make it change the color of icon use :
btn.tintColor = .white