如何解决点击
在使用 Xamarin 开发的 iOS 应用中,后退按钮的行为很奇怪。单击文本有时/很少会使文本消失。要返回上一屏幕,我必须单击箭头:
我还注意到,在不松开鼠标/手指的情况下按住文本时,文本总是消失:
任何可能导致这种行为的线索?我不认为应用是使用 Xamarin 创建的这一事实应该在这里发挥重要作用 - 它都是本机 iOS 视图控制器和视图。
解决方法
我想我已经找到了根本原因。我通过创建新的 UIBarButtonItem.Appearance
来在 UITextAttributes
代理上的主题中设置字体属性:
var proxyUIBarButton = UIBarButtonItem.Appearance;
proxyUIBarButton.SetTitleTextAttributes(new UITextAttributes { Font = UIFont.FromName(RegularFontName,20),TextColor = AtxBlue },UIControlState.Normal);
当属性基于默认属性时有效:
var attr = proxyUIBarButton.GetTitleTextAttributes(UIControlState.Application);
attr.Font = UIFont.FromName(RegularFontName,20);
attr.TextColor = AtxBlue;
proxyUIBarButton.SetTitleTextAttributes(attr,UIControlState.Normal);
希望这能帮助其他有同样问题的人。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。