This is a migrated thread and some comments may be shown as answers.

Can't set text color on iOS buttons

1 Answer 247 Views
Report a bug
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Tim
Top achievements
Rank 1
Tim asked on 25 Jun 2016, 05:15 AM

I am implementing a NativeScript app (in-browser client on Appbuild/platform). The UI spec has prescribed white text on buttons. However on ios the text still appears blue. It's all ok and looking good on Android.

If I try to set the color on the <button> class or in a css class (and add that in the view XML) it has no effect. I can use the style="color: white;" in the XML forms. This does seem to work. However it isn't good enough, because in my code I am wanting to switch between black, white and gray. Assigning the color in code doesn't seem to have any effect on ios (iPad), though that is all working as intended in Android.

 

   b0.color = "black";  // no effect on IOS. Ok on Android

I'm testing via livesync with the companion app. Downloading a package didn't make any difference either. Button text was still blue.

 

Any help would be appreciated. Thanks, Tim

 

 

1 Answer, 1 is accepted

Sort by
0
Nick Iliev
Telerik team
answered on 28 Jun 2016, 08:13 AM
Hello Tim,

One possible solution is to try to changing the cssClass in your code behind.
For example 
page.css
.myButtonClass { color: red }

page.js
// instance of button or provide your XML-element with getViewById()
var myButton= new buttonModule.Button();
myButton.cssClass = "myButtonClass";

As I don't have your project to work with I can not test if that will solve your issue. However if you need further assistance please provide us with a sample code to reproduce the behaviour.

p.p. You can also set your Button text color explicitly for iOS
For example:
var app = require("application");
 
// to ensure your code will run on in ios app
if (app.ios) {
    var myButton = page.getViewById("myButton");
    myButton.ios.tintColor = UIColor.redColor(); // text color
    myButton.ios.backgroundColor = UIColor.blackColor(); // background color
}


Regards,
Nikolay Iliev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Report a bug
Asked by
Tim
Top achievements
Rank 1
Answers by
Nick Iliev
Telerik team
Share this question
or