ios - Swift - 如何以编程方式在它们之间创建带有两个文本和图像的按钮?

标签 ios objective-c iphone swift

如何以编程方式创建此按钮:

enter image description here

我已经试过了:

    buttonLike.setImage(UIImage(named: "imageLikeForButton"), forState: UIControlState.Normal)

    buttonLike.setTitle("Like ", forState: UIControlState.Normal)

    buttonLike.tintColor = UIColor(red: 170.0/255.0, green: 170.0/255.0, blue: 170.0/255.0, alpha: 1.0)

    buttonLike.transform = CGAffineTransformMakeScale(-1.0, 1.0)
    buttonLike.titleLabel!.transform = CGAffineTransformMakeScale(-1.0, 1.0)
    buttonLike.imageView!.transform = CGAffineTransformMakeScale(-1.0, 1.0)

但它只适用于一个文本和一个图像:

enter image description here

最佳答案

我认为最好创建一个 UIView 并为您的操作(按键等)使用 gesturerecognizer。

关于ios - Swift - 如何以编程方式在它们之间创建带有两个文本和图像的按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36098499/

相关文章:

ios - UIViewControllerTransitioningDelegate 在 UITableViewController 顶部显示弹出屏幕

Objective-C 和 C

iphone - 在哪个线程中调用 iOS 完成处理程序 block ?

ios - 如何更改 iOS 8 中 NSLayoutConstraint 的 'mutiplier' 属性的值

ios - 使用xcodebuild构建不同平台

iphone - 从服务器而不是客户端应用程序发布在Facebook墙上

iphone - 培训 iPhone 开发人员

iphone - 可编辑的 UITableView

ios - UICollectionViewCell宽度的动态变化

objective-c - 在 iOS 程序中比较 char 数组和字符串