ios - 是否可以在 Objective C 中获取 UIButton.layer.borderColor 的值

标签 ios objective-c uibutton

当我按下 UIButton 时,我想使用 UIButton.layer.borderColor 将 View 背景的颜色更改为该颜色。

如果可能的话,我很想知道怎么做!

最佳答案

类似的事情

override func viewDidLoad() {
        super.viewDidLoad()
            button.layer.borderWidth = 2
            button.layer.borderColor = UIColor.orangeColor().CGColor
}

@IBAction func buttonPressed(sender : UIButton){
        sender.selected = !sender.selected

        if sender.selected {
            sender.backgroundColor = UIColor(CGColor: sender.layer.borderColor)
        } else {
            sender.backgroundColor = UIColor.whiteColor()
        }
    }

关于ios - 是否可以在 Objective C 中获取 UIButton.layer.borderColor 的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32104884/

相关文章:

ios - 如何通过点击 UITableViewCell IOS7 来播放视频

javascript - 如何自动检测是否需要iScroll?

ios - 在 arc : EXC_BAD_ACCESS 中消失的 self.delegate

ios - 如何区分用户是快速点击 UIButton 还是在 Swift 中放置并按住它?

ios - 如何在 UITableView 中实现 Expandable - Collapsable UITableViewCell - IOS

ios - 应用仅在连接到 XCode 时崩溃

ios - 如何在不切换应用程序的情况下在 iOS 应用程序之间通信数据?

objective-c - 强制导航栏的标题动画

ios - MKmapView Overlay 绘图显示色 block iOS 10

ios - 在 iOS 中呈现弹出窗口时如何避免按钮色调颜色变化?