Closed jamesingreersc closed 1 year ago
Can you explain exactly why it's a problem that the GetTitleTextAttributes
method returns a UIStringAttributes
instead of a UITextAttributes
object? UIStringAttributes
should be a more accurate type.
As to your code, this should work:
var routeSegmentControlAttributes = segmentSaleType.GetTitleTextAttributes(UIControlState.Selected);
Hi @jamesingreersc. We have added the "need-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
@rolfbjarne The biggest problem with the return type is that it breaks the existing code. UIStringAttributes doesn't contain a TextColor property. I'm just trying to convert to .Net as close as possible to the existing code base.
UITextAttributes routeSegmentControlAttributes =routeSegmentControl.GetTitleTextAttributes(UIControlState.Selected); if (routeSegmentControlAttributes == null) routeSegmentControlAttributes = routeSegmentControl.GetTitleTextAttributes(UIControlState.Normal); if (routeSegmentControlAttributes == null) routeSegmentControlAttributes = new UITextAttributes() { Font = UIFont.FromName("System", 16), TextColor = UIColor.White }; routeSegmentControlAttributes.Font = UIFont.SystemFontOfSize(16, UIFontWeight.Regular); routeSegmentControlAttributes.TextColor = UIColor.White;
UIStringAttributes doesn't contain a TextColor property.
You can use the ForegroundColor property instead.
According to Apple's documentation, UITextAttributeTextColor
(the underlying field for UITextAttributes.TextColor) is deprecated in favor of NSForegroundColorAttributeName
instead (the underlying field for UIStringAttributes.ForegroundColor).
@rolfbjarne Awesome. Just tried that and it works great. Thanks for your help! James
Both below methods reside in UISegmentedControl
Steps to Reproduce
Expected Behavior
Method should return a UITextAttributes object like in Xamarin.IOS
Actual Behavior
Actual return value is a UIStringAttributes object
Environment
Visual studio 2022 preview. Windows 10. Microsoft IOS .Net 6
Version information
``` ```Build Logs
Severity Code Description Project File Line Suppression State Error CS0029 Cannot implicitly convert type 'UIKit.UIStringAttributes' to 'UIKit.UITextAttributes' DSDRouteManager.IOS
Example Project (If Possible)