I figured out a solution, but it's a bit ugly. I wish that TextTransform
just worked out of the box.
protected override void OnAttached()
{
var effect = Element.Effects.OfType<UppercaseRoutingEffect>().FirstOrDefault();
if(effect != null && Control is UIKit.UIView view) {
foreach(var sub in FindViews(view, v => v is UIKit.UILabel)) {
var label = (UIKit.UILabel)sub;
label.Text = label.Text?.ToUpperInvariant() ?? label.Text;
}
}
}
private static IEnumerable<UIKit.UIView> FindViews(UIKit.UIView view, Func<UIKit.UIView, bool> checker)
{
List<UIKit.UIView> results = new();
void RecurseView(UIKit.UIView view)
{
if(checker(view)) {
results.Add(view);
}
foreach(var sub in view.Subviews) {
RecurseView(sub);
}
}
RecurseView(view);
return results;
}