英文:
Bordeless editor maui UITextView Does not contain a definition for BorderStyle
问题
我试图在编辑器中去掉下划线,但我一直得到"UITextView不包含BorderStyle的定义"的错误。Android 没问题,但 iOS 报错。
public class BorderlessEditor : Editor
{
public static void Setup()
{
Microsoft.Maui.Handlers.EditorHandler.Mapper.AppendToMapping("BorderlessEditor", (handler, view) =>
{
if (view is BorderlessEditor)
{
#if __ANDROID__
handler.PlatformView.SetBackgroundColor(Android.Graphics.Color.Transparent);
#elif __IOS__
if (handler.NativeView is UIKit.UITextView textView)
{
textView.BackgroundColor = UIKit.UIColor.Clear;
textView.BorderStyle = UIKit.UITextBorderStyle.None;
}
#endif
}
});
}
}
英文:
I am trying to remove the underline in the editor but I keep getting " UITextView Does not contain a definition for BorderStyle" Android is fine but iOS is complaining
public class BorderlessEditor : Editor
{
public static void Setup()
{
Microsoft.Maui.Handlers.EditorHandler.Mapper.AppendToMapping("BorderlessEditor", (handler, view) =>
{
if (view is BorderlessEditor)
{
#if __ANDROID__
handler.PlatformView.SetBackgroundColor(Android.Graphics.Color.Transparent);
#elif __IOS__
if (handler.NativeView is UIKit.UITextView textView)
{
textView.BackgroundColor = UIKit.UIColor.Clear;
textView.BorderStyle = UIKit.UITextBorderStyle.None;
}
#endif
}
});
}
}
答案1
得分: 1
尝试这个?
Microsoft.Maui.Handlers.EditorHandler.Mapper.AppendToMapping("Borderless", (handler, view) =>
{
if (view is Editor)
{
#if ANDROID
handler.PlatformView.Background = null;
handler.PlatformView.SetBackgroundColor(Android.Graphics.Color.Transparent);
#elif IOS || MACCATALYST
handler.PlatformView.BackgroundColor = UIKit.UIColor.Clear;
handler.PlatformView.Layer.BorderWidth = 0;
#endif
}
});
英文:
Try this ?
Microsoft.Maui.Handlers.EditorHandler.Mapper.AppendToMapping("Borderless", (handler, view) =>
{
if (view is Editor)
{
#if ANDROID
handler.PlatformView.Background = null;
handler.PlatformView.SetBackgroundColor(Android.Graphics.Color.Transparent);
#elif IOS || MACCATALYST
handler.PlatformView.BackgroundColor = UIKit.UIColor.Clear;
handler.PlatformView.Layer.BorderWidth = 0;
#endif
}
});
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论