UIButton with low alpha background but fully opaque title?
How can I make a UIButton with a transparent background but a non-transparent title? I tried the following
button.alpha = .5;
button.titleLabel.alpha = 1;
That did not have the desired effect. Other suggestions?
ios objective-c
add a comment |
How can I make a UIButton with a transparent background but a non-transparent title? I tried the following
button.alpha = .5;
button.titleLabel.alpha = 1;
That did not have the desired effect. Other suggestions?
ios objective-c
Subclass the button and do it internally?
– Mike
Jan 28 '16 at 20:31
add a comment |
How can I make a UIButton with a transparent background but a non-transparent title? I tried the following
button.alpha = .5;
button.titleLabel.alpha = 1;
That did not have the desired effect. Other suggestions?
ios objective-c
How can I make a UIButton with a transparent background but a non-transparent title? I tried the following
button.alpha = .5;
button.titleLabel.alpha = 1;
That did not have the desired effect. Other suggestions?
ios objective-c
ios objective-c
asked Jan 28 '16 at 20:11
helloBhelloB
93211444
93211444
Subclass the button and do it internally?
– Mike
Jan 28 '16 at 20:31
add a comment |
Subclass the button and do it internally?
– Mike
Jan 28 '16 at 20:31
Subclass the button and do it internally?
– Mike
Jan 28 '16 at 20:31
Subclass the button and do it internally?
– Mike
Jan 28 '16 at 20:31
add a comment |
3 Answers
3
active
oldest
votes
just make only the background 0.5 alpha
button.backgroundColor = [UIColor colorWithRed:100.0/255.0 green:100.0/255.0 blue:100.0/255.0 alpha:0.5];
Can I do that without doing it by setting the color?
– helloB
Jan 28 '16 at 20:19
are you have background image on the button ?
– Mohamed Helmy
Jan 28 '16 at 20:21
you can read existing backgroundColor and create new background color out of it by keeping all the components same except alpha
– ishaq
Jan 28 '16 at 20:21
add a comment |
Just try playing with different parts of your button.
For example, if that is the image, that you want with alpha 0.5, then try this:
[button setImage:[UIImage imageNamed:@"myImage"] forState:UIControlStateNormal];
button.imageView.alpha = 0.5;
or even this:
button.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"myImage"]];
button.backgroundColor = [button.backgroundColor colorWithAlphaComponent:0.5];
You can even add alpha directly onto UIImage --
How to set the opacity/alpha of a UIImage?
The above link would help if you are setting the image via:
[button setBackgroundImage:[UIImage imageNamed:@"myImage"] forState:UIControlStateNormal];
I don't know other solutions, though. Hope this helps.
add a comment |
you can use this:
swift button.backgroundColor = UIColor.white.withAlphaComponent(0.7)
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f35071090%2fuibutton-with-low-alpha-background-but-fully-opaque-title%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
just make only the background 0.5 alpha
button.backgroundColor = [UIColor colorWithRed:100.0/255.0 green:100.0/255.0 blue:100.0/255.0 alpha:0.5];
Can I do that without doing it by setting the color?
– helloB
Jan 28 '16 at 20:19
are you have background image on the button ?
– Mohamed Helmy
Jan 28 '16 at 20:21
you can read existing backgroundColor and create new background color out of it by keeping all the components same except alpha
– ishaq
Jan 28 '16 at 20:21
add a comment |
just make only the background 0.5 alpha
button.backgroundColor = [UIColor colorWithRed:100.0/255.0 green:100.0/255.0 blue:100.0/255.0 alpha:0.5];
Can I do that without doing it by setting the color?
– helloB
Jan 28 '16 at 20:19
are you have background image on the button ?
– Mohamed Helmy
Jan 28 '16 at 20:21
you can read existing backgroundColor and create new background color out of it by keeping all the components same except alpha
– ishaq
Jan 28 '16 at 20:21
add a comment |
just make only the background 0.5 alpha
button.backgroundColor = [UIColor colorWithRed:100.0/255.0 green:100.0/255.0 blue:100.0/255.0 alpha:0.5];
just make only the background 0.5 alpha
button.backgroundColor = [UIColor colorWithRed:100.0/255.0 green:100.0/255.0 blue:100.0/255.0 alpha:0.5];
answered Jan 28 '16 at 20:17
Mohamed HelmyMohamed Helmy
456618
456618
Can I do that without doing it by setting the color?
– helloB
Jan 28 '16 at 20:19
are you have background image on the button ?
– Mohamed Helmy
Jan 28 '16 at 20:21
you can read existing backgroundColor and create new background color out of it by keeping all the components same except alpha
– ishaq
Jan 28 '16 at 20:21
add a comment |
Can I do that without doing it by setting the color?
– helloB
Jan 28 '16 at 20:19
are you have background image on the button ?
– Mohamed Helmy
Jan 28 '16 at 20:21
you can read existing backgroundColor and create new background color out of it by keeping all the components same except alpha
– ishaq
Jan 28 '16 at 20:21
Can I do that without doing it by setting the color?
– helloB
Jan 28 '16 at 20:19
Can I do that without doing it by setting the color?
– helloB
Jan 28 '16 at 20:19
are you have background image on the button ?
– Mohamed Helmy
Jan 28 '16 at 20:21
are you have background image on the button ?
– Mohamed Helmy
Jan 28 '16 at 20:21
you can read existing backgroundColor and create new background color out of it by keeping all the components same except alpha
– ishaq
Jan 28 '16 at 20:21
you can read existing backgroundColor and create new background color out of it by keeping all the components same except alpha
– ishaq
Jan 28 '16 at 20:21
add a comment |
Just try playing with different parts of your button.
For example, if that is the image, that you want with alpha 0.5, then try this:
[button setImage:[UIImage imageNamed:@"myImage"] forState:UIControlStateNormal];
button.imageView.alpha = 0.5;
or even this:
button.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"myImage"]];
button.backgroundColor = [button.backgroundColor colorWithAlphaComponent:0.5];
You can even add alpha directly onto UIImage --
How to set the opacity/alpha of a UIImage?
The above link would help if you are setting the image via:
[button setBackgroundImage:[UIImage imageNamed:@"myImage"] forState:UIControlStateNormal];
I don't know other solutions, though. Hope this helps.
add a comment |
Just try playing with different parts of your button.
For example, if that is the image, that you want with alpha 0.5, then try this:
[button setImage:[UIImage imageNamed:@"myImage"] forState:UIControlStateNormal];
button.imageView.alpha = 0.5;
or even this:
button.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"myImage"]];
button.backgroundColor = [button.backgroundColor colorWithAlphaComponent:0.5];
You can even add alpha directly onto UIImage --
How to set the opacity/alpha of a UIImage?
The above link would help if you are setting the image via:
[button setBackgroundImage:[UIImage imageNamed:@"myImage"] forState:UIControlStateNormal];
I don't know other solutions, though. Hope this helps.
add a comment |
Just try playing with different parts of your button.
For example, if that is the image, that you want with alpha 0.5, then try this:
[button setImage:[UIImage imageNamed:@"myImage"] forState:UIControlStateNormal];
button.imageView.alpha = 0.5;
or even this:
button.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"myImage"]];
button.backgroundColor = [button.backgroundColor colorWithAlphaComponent:0.5];
You can even add alpha directly onto UIImage --
How to set the opacity/alpha of a UIImage?
The above link would help if you are setting the image via:
[button setBackgroundImage:[UIImage imageNamed:@"myImage"] forState:UIControlStateNormal];
I don't know other solutions, though. Hope this helps.
Just try playing with different parts of your button.
For example, if that is the image, that you want with alpha 0.5, then try this:
[button setImage:[UIImage imageNamed:@"myImage"] forState:UIControlStateNormal];
button.imageView.alpha = 0.5;
or even this:
button.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"myImage"]];
button.backgroundColor = [button.backgroundColor colorWithAlphaComponent:0.5];
You can even add alpha directly onto UIImage --
How to set the opacity/alpha of a UIImage?
The above link would help if you are setting the image via:
[button setBackgroundImage:[UIImage imageNamed:@"myImage"] forState:UIControlStateNormal];
I don't know other solutions, though. Hope this helps.
edited May 23 '17 at 11:59
Community♦
11
11
answered Jan 28 '16 at 20:32
OlDorOlDor
1,046414
1,046414
add a comment |
add a comment |
you can use this:
swift button.backgroundColor = UIColor.white.withAlphaComponent(0.7)
add a comment |
you can use this:
swift button.backgroundColor = UIColor.white.withAlphaComponent(0.7)
add a comment |
you can use this:
swift button.backgroundColor = UIColor.white.withAlphaComponent(0.7)
you can use this:
swift button.backgroundColor = UIColor.white.withAlphaComponent(0.7)
answered Nov 14 '18 at 13:00
m.alqadim.alqadi
13117
13117
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f35071090%2fuibutton-with-low-alpha-background-but-fully-opaque-title%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Subclass the button and do it internally?
– Mike
Jan 28 '16 at 20:31