Background color for segmented control in IOS - colors

I have a segmented control which needs to be blue when selected, and white when unselected. Im facing problems to set the tint color when unselected, as for some reason, it always turns out to be grey.
This is what it looks like:
The blue border is actually a UIView with some border color, and within it I stuck the segmented control. But I cant change the grey background ( which should be white ).
I tried doing all of this :
sc.selectedSegmentTintColor = UIColor.blue
sc.setTitleTextAttributes([NSAttributedString.Key.font: UIFont.preferredFont(forTextStyle: .body),NSAttributedString.Key.foregroundColor: UIColor.white], for: .selected)
sc.setTitleTextAttributes([NSAttributedString.Key.font: UIFont.preferredFont(forTextStyle: .body),NSAttributedString.Key.foregroundColor: UIColor.blue], for: .normal)
sc.tintColor = .white
sc.backgroundColor = .white
sc.isOpaque = true
with no success. :(

It's working fine with background color
self.backgroundColor = .red
It's working fine in iOS 13

Related

How to set UIDatePicker background color to white in xamarin.ios for ios 14?

I am hiding a label by a UIDatePicker in a xamarin.ios app. I changed the style of the datepicker label but can't change the background to white. Here is my code:
datePickerDateFrom.Frame = lblFromDate.Frame;
datePickerDateFrom.Subviews[0].Subviews[0].SetValueForKey(UIColor.White, new NSString("backgroundColor"));
datePickerDateFrom.Subviews[0].Subviews[0].TintColor = UIColor.Black;
datePickerDateFrom.Subviews[0].Subviews[0].Layer.BorderWidth = 1;
datePickerDateFrom.Subviews[0].Subviews[0].Layer.CornerRadius = 6;
datePickerDateFrom.Subviews[0].Subviews[0].Layer.BorderColor = UIColor.FromRGB(0, 184, 212).CGColor;
datePickerDateFrom.SizeToFit();
Add(datePickerDateFrom);
And the result is:
Any other color works but if I set the color to white it remains this ash color that's why sometimes there is a color difference inside the blue border when the short date format is selected. I don't know is it possible to align the value inside the frame and specify any fixed date format(as sometimes it displays 3 letter of month name when gets larger space). For now changing the background color to white would be a great help. Thanks in advance.

How to identify colour of an icon of presence

I am new to espresso .My test scenario involves to check the colour of the icon during the presence.For example if person X in available there is small green icon next to his name, if he is busy icon change to red
I am not quit sure how I can test colour of the specific icon R.id.presence
I do understand I need to use drawable but not sure how
You can try something like this. Try to find the element(probably R.id.presence in your case) and then try to get the background color of the element. Now compare it with the expected color.
Sample code for a button where green as background color is being verified.
Button btn = (Button) findViewById(R.id.my_button);
Drawable buttonBackground = btn.getBackground();
ColorDrawable btn_color = (ColorDrawable) btn.getBackground();
int color = btn_color.getColor();
if (color == R.color.green) {
log("color is green");
}
Hope it helps :)

the change of the status bar changes the title of navigation bar in ios. xamarin.forms

I am facing a problem Because in my IOS app I need a status bar with white textcolor, and I need a nav bar with a orange title color and a white back button as in the image But with a white status bar:
For change the status bar color I did it in the app.xaml.cs in the pcl project
MainPage = new NavigationPage(new Views.Splash2()) { BarTextColor = Color.White };
it changed my status bar color as I want but the nav bar title is white know...How can I solve this problem? I need the first photo layout but with a white status bar like the second...
I am working with xamarin.forms
-----------------------------edit---------------------------
Searching, I know now that the status bar color of ios in xamarin.forms depends of nav bar text color, then, if you use a color that is considered "light" (it need to have a value to blue, that can't be 0) the statubar text color is white, else it is black...
I am using a light orange (which is not the color that I wanted, but it's ok, it's better)...I saw the solution here
https://forums.xamarin.com/discussion/51602/on-ios-can-i-set-the-statusbar-text-color-independently-of-the-navigationpage-bartextcolor
now, my status bar text is white and my nav bar text is orange, but the problem is: in ios the nav bar back button is orange to when I set this color with
MainPage = new NavigationPage(new Views.Splash2()) { BarTextColor = Color.FromHex("#ff9e14") };
and I need it in white color, as I showed here.
How it is now:
How can I change only the nav bar back button color?
It's really complicated to understand, because the status bar color changes only if you change the nav bar text color...if you use "light colors" (with a good quantity of blue), the status bar changes to white, but if you use a color with no blue the statusbar text will be black...Besides that...when you change the nav bar text color of the pages in app.xaml.cs as I showed in my question, in ios, not in android, the back button of the nav bar will have the same color that you setted to the title of the nav bar...if you want a different color for the back button, you can create a custom navigation renderer and inside that use this line
this.NavigationBar.TintColor = UIColor.colorThatYouWant;
That is it ! A hell ¬¬'

Blue color table border using docx4j

I'm using docx4j to create a docx file. I want my table border to be blue colored but it is only showing black.how to do this?
Here is my code:
table.setTblPr(new TblPr());
CTBorder border = new CTBorder();
border.setColor("FFF");
border.setSz(new BigInteger("0"));
border.setSpace(new BigInteger("0"));
border.setVal(STBorder.SINGLE);
TblBorders borders = new TblBorders();
borders.setBottom(border);
borders.setLeft(border);
borders.setRight(border);
borders.setTop(border);
borders.setInsideH(border);
borders.setInsideV(border);
table.getTblPr().setTblBorders(borders);
You need to set the color attribute of the border in question. Your example code appears to have you setting a colour of 'FFF' which obviously won't work if it needs to be blue! I would suggest trying a straight blue in hex and going from there. For example a (very) standard blue would be:
CTBorder border = new CTBorder();
border.setColor("0000FF");

Problems encountered in changing a CRichEditCtrl selection color

I have written the following code after creating the CRichEditCtrl
// 06112010 : The following code was added to highlight the textselection in black color instead of the default blue color of CRichEditCtrl. - 1311
{
m_EditControl.SetSel(0,100);
CHARFORMAT2 cf1;
cf1.cbSize = sizeof(CHARFORMAT2);
m_EditControl.GetSelectionCharFormat(cf1);
cf1.dwMask = CFM_BACKCOLOR ;
cf1.dwEffects &= ~CFE_AUTOBACKCOLOR;
cf1.crBackColor = RGB(0,0,0);
m_EditControl.SetSelectionCharFormat(cf1);
m_EditControl.Invalidate();
}
After this I am adding text, but the selection still comes in blue color instead of Black. Could someone please tell me what I am doing wrong??
Thanks,
DeV
You can't do it using SetSelectionCharFormat, which will only reformat the selected text. What you're asking for is an owner draw rich edit control, which is going to be more work than just deriving your own custom window from CWnd and implementing your own WM_PAINT handler.

Resources