MAUI๋ก IP์ค์บ ๊ธฐ๋ฅ์ ๊ตฌํ ์ค์
๋๋ค. IP์
๋ ฅํ๋ Entry์ Focus๋์๋๋ ๊ฒ์ ์ Focus๊ฐ ๋น ์ง๋ฉด ํ์์ผ๋ก ์ฒ๋ฆฌ ํ๋ ค๊ณ ํฉ๋๋ค.
๊ธฐ๋ณธ๊ฐ์ผ๋ก Focus ๋์ ๋ ํ๋์ ๋ฐ์ค์ด ๋ค์ด์์ด์ ํ์์ผ๋ก ๋ฐ๊พธ๊ฒ ์ค์ ํ๋๋ ๋์ค๋ก ๋์ค๋ ๋ฌธ์ ๊ฐ ์๊ฒผ์ต๋๋ค.
์ด๋ป๊ฒ๋ค ํด๊ฒฐํ์๋์? ๊ฒ์ ํด๋ณด๋ Entry์ ๋ฐ์ค ๋นผ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๊ฐ ์๋๋ฐ ๋ค๋ค ์ด ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฐ์๋์?
xaml
<Entry x:Name="StartIpEntry"
Text="192.168.0.1"
Keyboard="Default"
Placeholder="Start IP"
FontSize="20"
HorizontalTextAlignment="Center"
BackgroundColor="Transparent"
TextChanged="OnStartIpTextChanged" />
cs
public IpScanPage()
{
InitializeComponent();
BindingContext = this;
// ๋ฐ์ค ์ค์ ํ๋ ๋ถ๋ถ
StartIpEntry.Focused += (s, e) => StartIpUnderline.Color = Color.FromArgb("#1E3A5F");
StartIpEntry.Unfocused += (s, e) => StartIpUnderline.Color = Color.FromArgb("#9E9E9E");
EndIpEntry.Focused += (s, e) => EndIpUnderline.Color = Color.FromArgb("#1E3A5F");
EndIpEntry.Unfocused += (s, e) => EndIpUnderline.Color = Color.FromArgb("#9E9E9E");
}
1 Like
๋ง์ํ์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๊ฐ ์ ๊ฐ ์๊ฐํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ผ๋ฉด ๋ค์ดํฐ๋ธ ์ปจํธ๋กค์ ์ง์ ์ ๊ทผํ์ฌ Border ์ปฌ๋ฌ(๋ฐ์ค)๋ฅผ ์ง์ฐ๋ ๋ฐฉ์์ด๋ผ์ ์ง์ ๊ตฌํํ์ฌ ์ฐ์
๋ ์๊ด์์ต๋๋ค.
๋ค๋ง, ์ฌ๋ ค์ฃผ์ ์์ ๋ ๋ค์ดํฐ๋ธ ํ๋ ์์ํฌ์ ์ปจํธ๋กค์ ์ ๊ทผํ์ฌ ํ ๋ฐฉ์์ด ์๋๋๋ค.
์๋์ ๊ฐ์ ์ฝ๋(Gemini์์ฒญ์ผ๋ก ๋ง๋ ์์ ์ด๊ธฐ์ ํ๋ฆด ์ ์์ต๋๋ค.)
// Entry ๋ฐ์ค ์ ๊ฑฐ ํธ๋ค๋ฌ ์ถ๊ฐ
Microsoft.Maui.Handlers.EntryHandler.Mapper.AppendToMapping("NoUnderline", (handler, view) =>
{
#if ANDROID
// ์๋๋ก์ด๋: ๋ฐฐ๊ฒฝ์์ ํฌ๋ช
ํ๊ฒ ํ๊ฑฐ๋ null๋ก ์ค์ ํ์ฌ ๋ฐ์ค ์ ๊ฑฐ
handler.PlatformView.BackgroundTintList = Android.Content.Res.ColorStateList.ValueOf(Android.Graphics.Color.Transparent);
#elif IOS || MACCATALYST
// iOS: ํ
๋๋ฆฌ ์คํ์ผ์ None์ผ๋ก ์ค์
handler.PlatformView.BorderStyle = UIKit.UITextBorderStyle.None;
#endif
});
ํ๋ซํผ๋ณ ํธ๋ค๋ฌ ์ค์ ์ด ๋ณต์กํ๊ณ , OS๋ณ ๋์์ธ ํํธํ๊ฐ ๋ถ๋ด๋๋ค๋ฉด DrawnUI ๋ฅผ ์ฌ์ฉ์ ๊ณ ๋ คํด๋ณผ ๋งํฉ๋๋ค.
DrawnUI๋ ๊ฐ OS์ ๋ค์ดํฐ๋ธ ์ปจํธ๋กค์ ์์กดํ์ง ์๊ณ , Skia ๊ธฐ๋ฐ์ผ๋ก ์ง์ ์ปจํธ๋กค์ ๋ ๋๋งํ๋ ๋ฐฉ์์ด๊ธฐ ๋๋ฌธ์
๋ชจ๋ ํ๋ซํผ์์ ๋์ผํ UI๋ฅผ ๊ตฌํํ ์ ์์ผ๋ฉฐ, ํฝ์
๋จ์๊น์ง ์ผ๊ด๋(ํผํํธ ํฝ์
) ๊ฒฐ๊ณผ๋ฅผ ์ ๊ณตํฉ๋๋ค.
1 Like