iOS - Setting UIButton background color only colors the corners(iOS - 设置 UIButton 背景颜色只为角落着色)
问题描述
I'm trying to customize my button by changing their colors, but when I use either:
self.loginButton.layer.backgroundColor = [UIColor colorWithRed:0.0 green:157.0/255.0 blue:223.0/255.0 alpha:1.0].CGColor;
or
self.loginButton.backgroundColor = [UIColor colorWithRed:0.0 green:157.0/255.0 blue:223.0/255.0 alpha:1.0];
All I get is this result:
What I want to do is change the white color to blue, any idea what I'm doing wrong?
You're using a round rect button which is pretty ugly, and pretty hard to customise.
You can create a custom type button and use a background image, or create a custom type button and round the corners and set the background colour of the layer yourself.
If you want to get really fancy there is a nice tutorial here which can give you any-sized gradient type buttons using layers, no image files required.
这篇关于iOS - 设置 UIButton 背景颜色只为角落着色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:iOS - 设置 UIButton 背景颜色只为角落着色


基础教程推荐
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01