Я использую Материальные компоненты в приложении iOS Xamarin и хотел бы установить ширину MDCTabBar на что-то большее, например 8 dp.
Как я понимаюЯ должен предоставить пользовательский объект, реализующий TabBarIndicatorTemplate
для SelectionIndicatorTemplate
.
Итак, предположим, что я инициализирую панель вкладок:
tabBar = new TabBar();
tabBar.Items = new UITabBarItem[] {
new UITabBarItem("One", null, 0),
new UITabBarItem("Two", null, 0)
};
tabBar.Alignment = TabBarAlignment.Justified;
tabBar.ItemAppearance = TabBarItemAppearance.Titles;
tabBar.TitleTextTransform = TabBarTextTransform.None;
И затем использую мой пользовательский CustomTabBarIndicatorTemplate
:
tabBar.SelectionIndicatorTemplate = new CustomTabBarIndicatorTemplate();
, который реализован следующим образом:
private class CustomTabBarIndicatorTemplate : TabBarIndicatorTemplate
{
public override TabBarIndicatorAttributes IndicatorAttributesForContext(ITabBarIndicatorContext context)
{
var bounds = context.Bounds;
var attr = new TabBarIndicatorAttributes();
var frame = new CGRect(bounds.GetMinX(), bounds.GetMaxY() - 8, bounds.Width, 8);
attr.Path = UIBezierPath.FromRect(frame);
return attr;
}
}
К сожалению, это вызывает собственный сбой на iOS:
=================================================================
Native Crash Reporting
=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
=================================================================
Native stacktrace:
=================================================================
0x10dc02ae5 - /Users/user/Library/Developer/CoreSimulator/Devices/44BEABB1-FBEC-48AB-8CE3-F04C3969A12A/data/Containers/Bundle/Application/23FCADDC-6D6C-4DCA-8C0F-1D2CCF19D914/MyApp.iOS.app/MyApp.iOS : mono_dump_native_crash_info
0x10dbf6a25 - /Users/user/Library/Developer/CoreSimulator/Devices/44BEABB1-FBEC-48AB-8CE3-F04C3969A12A/data/Containers/Bundle/Application/23FCADDC-6D6C-4DCA-8C0F-1D2CCF19D914/MyApp.iOS.app/MyApp.iOS : mono_handle_native_crash
0x10dc09d61 - /Users/user/Library/Developer/CoreSimulator/Devices/44BEABB1-FBEC-48AB-8CE3-F04C3969A12A/data/Containers/Bundle/Application/23FCADDC-6D6C-4DCA-8C0F-1D2CCF19D914/MyApp.iOS.app/MyApp.iOS : mono_sigsegv_signal_handler_debug
0x11e7c7b5d - /usr/lib/system/libsystem_platform.dylib : _sigtramp
0x10dc820b9 - /Users/user/Library/Developer/CoreSimulator/Devices/44BEABB1-FBEC-48AB-8CE3-F04C3969A12A/data/Containers/Bundle/Application/23FCADDC-6D6C-4DCA-8C0F-1D2CCF19D914/MyApp.iOS.app/MyApp.iOS : mono_de_add_pending_breakpoints
0x14593b306 - Unknown
=================================================================
Basic Fault Address Reporting
=================================================================
Memory around native instruction pointer (0x11d03080a):0x11d0307fa 00 00 00 00 00 90 4c 8b 57 08 48 8b 3f 49 89 f3 ......L.W.H.?I..
0x11d03080a 45 23 5a 18 49 c1 e3 04 4d 03 5a 10 49 3b 33 75 E#Z.I...M.Z.I;3u
0x11d03081a 04 41 ff 63 08 49 83 3b 01 76 0d 49 83 c3 10 49 .A.c.I.;.v.I...I
0x11d03082a 3b 33 75 f1 41 ff 63 08 72 1b 4d 8b 5b 08 eb 0a ;3u.A.c.r.M.[...
=================================================================
Managed Stacktrace:
=================================================================
at <unknown> <0xffffffff>
at ApiDefinition.Messaging:IntPtr_objc_msgSendSuper <0x00135>
at MaterialComponents.TabBarIndicatorTemplate:.ctor <0x00342>
at CustomTabBarIndicatorTemplate:.ctor <0x00072>
at MyApp.iOS.Views.[REDACTED].[REDACTED]ViewController:SetLayout <0x00a32>
at MyApp.iOS.Views.BaseViewController`1:PrepareLayout <0x001b0>
at MyApp.iOS.Views.BaseViewController`1:ViewDidLoad <0x000fa>
at System.Object:runtime_invoke_void__this__ <0x001a5>
at <unknown> <0xffffffff>
at UIKit.UIApplication:UIApplicationMain <0x00251>
at UIKit.UIApplication:Main <0x000b2>
at UIKit.UIApplication:Main <0x00132>
at MyApp.iOS.Application:Main <0x00092>
at <Module>:runtime_invoke_void_object <0x001a8>
=================================================================
Как мне правильно реализовать это?