첨부 소스 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

TestProject.zip
0.15MB

▶ MauiProgram.cs

using Microsoft.Maui.LifecycleEvents;
using System.Diagnostics;

namespace TestProject;

/// <summary>
/// MAUI 프로그램
/// </summary>
public static class MauiProgram
{
    //////////////////////////////////////////////////////////////////////////////////////////////////// Method
    ////////////////////////////////////////////////////////////////////////////////////////// Public

    #region MAUI 앱 생성하기 - CreateMauiApp()

    /// <summary>
    /// MAUI 앱 생성하기
    /// </summary>
    /// <returns>MAUI 앱</returns>
    public static MauiApp CreateMauiApp()
    {
        MauiAppBuilder builder = MauiApp.CreateBuilder();

        builder.UseMauiApp<App>()
            .ConfigureFonts
            (
                fontCollection =>
                {
                    fontCollection.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
                }
            )
            .ConfigureLifecycleEvents
            (
                lifecycleBuilder =>
                {
#if ANDROID
                    lifecycleBuilder.AddAndroid
                    (
                        androidLifecycleBuilder => androidLifecycleBuilder.OnActivityResult
                        (
                            (activity, requestCode, resultCode, data) => LogEvent("액티비티 결과시", requestCode.ToString())
                        )
                        .OnStart((activity) => LogEvent("시작시"))
                        .OnCreate((activity, bundle) => LogEvent("생성시"))
                        .OnBackPressed((activity) => LogEvent("뒤로 가기 버튼 클릭시"))
                        .OnStop((activity) => LogEvent("중단시"))
                    );
#endif

                    static bool LogEvent(string eventName, string type = null)
                    {
                        Debug.WriteLine($"수명 주기 이벤트 : {eventName}{(type == null ? string.Empty : $" ({type})")}");

                        return true;
                    }
                }
            );

        return builder.Build();
    }

    #endregion
}
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요