“Borderless editor maui UITextView” 不包含 BorderStyle 的定义。

huangapple go评论65阅读模式
英文:

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>



huangapple
  • 本文由 发表于 2023年4月13日 19:00:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/76004632.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定