ํ‹ฐ์Šคํ† ๋ฆฌ ๋ทฐ

728x90
๋ฐ˜์‘ํ˜•

๐Ÿ‘‰ ๋‚ด์šฉ

iOS 17 containerBackground API error ์™€ extra padding ์ด ์ƒ๊ธฐ๋Š” ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

  • iOS 17 ์ ์šฉ ํ›„์— ์ž ๊ธˆํ™”๋ฉด ์œ„์ ฏ์ด ์ œ๋Œ€๋กœ ๋ณด์ด์ง€ ์•Š๋Š” ์ด์Šˆ๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค. Xcode ์—์„œ ํ•œ ๋ฒˆ ์‚ดํŽด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

Xcode ์—์„œ preview ๋กœ ํ™•์ธํ•ด๋ณด๋ คํ–ˆ๋”๋‹ˆ ํ•ด๋‹น ๊ฒฝ๊ณ ๊ฐ€ ๋“ฑ์žฅํ–ˆ์Šต๋‹ˆ๋‹ค.

2

“Ensure that you have called the containerBackground(for: .widget) {…} modifier in your widget view.”

๐Ÿ‘‰ containerBackground(for:alignment:content:)

๊ฐœ๋ฐœ์ž ๋ฌธ์„œ๋ฅผ ์‚ดํŽด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

containerBackground(for:alignment:content:) | Apple Developer Documentation

3

๋ทฐ๋ฅผ ์‚ฌ์šฉํ•ด์„œ ๋‘˜๋Ÿฌ์‹ธ๋Š” container ์˜ container background ๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.

Parameters

  • alignment :The alignment that the modifier uses to position the implicit ZStack that groups the background views. The default is center.
  • container :The container that will use the background.
  • content : The view to use as the background of the container.

Discussion

ํ•ด๋‹น modifier ๋Š” ์ „์ฒด parent container ๋ฅผ ์ž๋™์œผ๋กœ ์ฑ„์šฐ๋Š” ์ ์—์„œ background(_:ignoresSafeAreaEdges:) ์™€ ๋‹ค๋ฆ…๋‹ˆ๋‹ค.

  • ์ ์šฉํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค!
if #available(iOSApplicationExtension 17.0, *) {
    Image("widgetEmpty")
         .resizable()
         .scaledToFill()
         .containerBackground(for: .widget) {
             // ...    
         }
} else {
     Image("widgetEmpty")
         .resizable()
         .scaledToFill()
}

์ด์ œ์•ผ ํ”„๋ฆฌ๋ทฐ์—์„œ ์—๋Ÿฌ ์—†์ด ํ™•์ธํ•  ์ˆ˜ ์žˆ๊ฒŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

background ๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ๋ผ๋„ containerBackground(for:) modifier ๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ์—๋Ÿฌ๋ฅผ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.

4

๐Ÿซข ??? ์ € ์—ฌ๋ฐฑ์€ ๋ญ์ง€?

๐Ÿšจ ํŠธ๋Ÿฌ๋ธ” ์ŠˆํŒ…

  • ๊ทธ๋Ÿฐ๋ฐ ์•„์ง ์™„์„ฑ์€ ์•„๋‹™๋‹ˆ๋‹ค! ์—๋Ÿฌ๊ฐ€ ๋‚˜์ง€ ์•Š์„ ๋ฟ์ด์ง€ ์ „์—๋Š” ์—†๋˜ padding ์ด ์ƒ๊ฒผ์Šต๋‹ˆ๋‹ค.

๋งŽ์€ ์ปค๋ฎค๋‹ˆํ‹ฐ์—์„œ๋„ iOS 17 widget extra padding ์— ๋Œ€ํ•œ ์งˆ๋ฌธ๋“ค์ด ์˜ฌ๋ผ์™€ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.

5

๐Ÿ‘‰ contentMarginsDisabled

contentMarginsDisabled() | Apple Developer Documentation

WWDC 23 > Bring widgets to new places ์—์„œ contentMarginsDisabled() ๋ฅผ ์‚ฌ์šฉํ•ด์„œ safe area ๋ฅผ ๋น„ํ™œ์„ฑํ™”ํ•  ์ˆ˜ ์žˆ๋‹ค๊ณ  ์•ˆ๋‚ดํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

๊ฐœ๋ฐœ์ž ๋ฌธ์„œ๋ฅผ ์‚ดํŽด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

6

default content margins ์ด๋ผ๊ณ  ํ‘œํ˜„ํ•˜๋Š” ๊ฒƒ์„ ๋ด์„œ ๊ธฐ๋ณธ์ ์œผ๋กœ ์„ค์ •๋˜๋Š” ๊ฐ’์„ ๋น„ํ™œ์„ฑํ™”ํ•˜๋Š” ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

Return Value :

default content margins ๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š” widget configuration ์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

Discussion :

content margins ์„ ๋น„ํ™œ์„ฑํ™”ํ•˜๋ฉด ์œ„์ ฏ์˜ content ์ฃผ์œ„์— ๋งˆ์ง„์„ ์ž๋™์œผ๋กœ ์ถ”๊ฐ€ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. custom margins ์„ ์ง€์ •ํ•˜๊ธฐ ์œ„ํ•ด์„œ widgetContentMargins ๋ฅผ padding() ๊ณผ ํ•จ๊ป˜ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

ํ•ด๋‹น modifier ๋Š” iOS 17, watchOS 10, macOS 14 ์ด์ „์˜ ๋ฒ„์ „์—์„œ๋Š” ์˜ํ–ฅ์„ ๋ฏธ์น˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

(์ฆ‰, ๋ณ„๋„์˜ if #available ๊ตฌ๋ฌธ์„ ์‚ฌ์šฉํ•˜์ง€ ์•Š์•„๋„ ๋ฉ๋‹ˆ๋‹ค!)


๋ฐ˜ํ™˜ ๊ฐ’์ด WidgetConfiguration ์ž…๋‹ˆ๋‹ค. ์ž ์‹œ ์ฝ”๋“œ๋ฅผ ์‚ดํŽด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

containerBackground(for:) ์ฒ˜๋Ÿผ View ๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹Œ WidgetConfiguration ์„ ๋ฐ˜ํ™˜ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์‚ฌ์šฉํ•˜๋Š” ์œ„์น˜๊ฐ€ ๋‹ค๋ฆ…๋‹ˆ๋‹ค.

struct ExampleEntryView: View {
    // ...

    var body: some View {
        if #available(iOSApplicationExtension 17.0, *) {
            Text("Example")
                // ...
                // โœ…
                .containerBackground(for: .widget) { }
        } else {
            Text("Example")
                // ...
    }
}

struct ExampleWidget: Widget {
    var body: some WidgetConfiguration {
        StaticConfiguration(kind: kind,
                            provider: Provider()) { entry in
            ExampleEntryView(entry: entry)
        }
        .configurationDisplayName("...")
        .description("...")
        .supportedFamilies([.systemSmall])
        // โœ…
        .contentMarginsDisabled()
        .containerBackgroundRemovable(false)
    }
}
// ๐Ÿšจ preview ์—์„œ๋Š” ์•„์ง๋„ content margin ์ด ์žˆ๋Š”๋ฐ์š”..???

// ๐Ÿ‘‰ preview ์—์„œ๋Š” `contentMarginsDisabled()` ๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š์•˜๊ธฐ ๋•Œ๋ฌธ์— ๊ทธ๋Ÿฐ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.
struct ExampleWidget_Previews: PreviewProvider {
    static var previews: some View {
        // View ๋ฅผ ์‚ฌ์šฉ
        ExampleEntryView(entry: ExampleEntry(date: Date()))
            .previewContext(WidgetPreviewContext(family: .systemSmall))
    }
}

preview ์—์„œ content margin ์ด ๋ณด์ด๋”๋ผ๋„ ์‹ค์ œ๋กœ ๋นŒ๋“œํ•ด๋ณด๋ฉด content margin ์ด ์‚ฌ๋ผ์ง์„ ํ™•์ธ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค!

 

ํ˜น์‹œ๋‚˜ํ•ด์„œ iPhone ์— ๊น”๋ ค์žˆ๋Š” ์•ฑ๋“ค์„ ์‚ดํŽด๋ดค์Šต๋‹ˆ๋‹ค. KREAM(ํฌ๋ฆผ ์‚ฌ๋ž‘ํ•ฉ๋‹ˆ๋‹ค๐Ÿงก), Instagram(์ธ์Šคํƒ€ ์‚ฌ๋ž‘ํ•ฉ๋‹ˆ๋‹ค๐Ÿซถ) ์•ฑ์—์„œ content margins ์„ ๋ณผ ์ˆ˜ ์žˆ์—ˆ์–ด์š”.. ์•„๋งˆ ์ด๊ฒƒ๋•Œ๋ฌธ์— ๋ ˆ์ด์•„์›ƒ์ด ์ข€ ์–ด๊ธ‹๋‚œ ๊ฒƒ์ฒ˜๋Ÿผ๋„ ๋ณด์˜€์Šต๋‹ˆ๋‹ค.(2023-11-08 ๊ธฐ์ค€)

์ด์™ธ์—๋„ ๋งŽ์€ ์•ฑ๋“ค์˜ ์œ„์ ฏ๋“ค์€ ์ด๋ฏธ ๋Œ€์‘ํ•˜๊ณ  ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค. "Please adopt containerBackground API" error ๋“ค์€ ์ฐพ์•„๋ณผ ์ˆ˜๋„ ์—†๋”๋ผ๊ตฌ์š”.

์ œ๊ฐ€ ์ง„ํ–‰ํ•˜๋Š” ํ”„๋กœ์ ํŠธ๋„ ์ด๋ฒˆ ์—…๋ฐ์ดํŠธ์—์„œ ๋Œ€์‘ ์˜ˆ์ •์ž…๋‹ˆ๋‹ค! ํ˜น์‹œ๋‚˜ ์—๋Ÿฌ๋ฅผ ๋ณด๊ณ  ์‹ถ์œผ์‹œ๋ฉด ์„ค์น˜ํ•ด์„œ ์œ„์ ฏ์œผ๋กœ ํ™•์ธํ•ด๋ณด์„ธ์š” ๐Ÿคฃ

 

‎๋‚˜๋‹ค NADA - ๋‚˜๋ฅผ ๋‹ค ๋‹ด์€ ๋ช…ํ•จ ์„œ๋น„์Šค

‎์ด์ œ๋Š” ๋‚˜๋‹ค๋กœ ๋ช…ํ•จ์„ ๊ตํ™˜ํ•˜๋ฉฐ ์‰ฝ๊ณ  ์žฌ๋ฏธ์žˆ๊ฒŒ ์„œ๋กœ๋ฅผ ์•Œ์•„๊ฐ€ ๋ณด์„ธ์š”. #1. ์ง์žฅ์—์„œ์˜ ๋‚˜๋„, ์นœ๊ตฌ๋“ค ์‚ฌ์ด์˜ ๋‚˜๋„, ๋•์งˆํ•  ๋•Œ์˜ ๋‚˜๋„ ๋ชจ๋‘ ๋‚˜๋‹ˆ๊นŒ! - ๋‚ด ์†์—” ๋‚ด๊ฐ€ ๋„ˆ๋ฌด๋‚˜ ๋งŽ์•„! ์ง์žฅ/๋•์งˆ/๊ธฐ๋ณธ

apps.apple.com

  • ๊นƒํ—ˆ๋ธŒ
 

GitHub - TeamNADA/NADA-iOS-ForRelease: ๋ฆด๋ฆฌ์ฆˆ๋ฅผ ๋ชฉํ‘œ๋กœ ํ•˜๋Š” ๋ฏผ์žฌ์ด์ค€ํ˜„๊ทœ์˜ ์œผ๋ผ์ฐจ์ฐจ๐Ÿฆพ ๋Œ€์†Œ๋™๐Ÿงจ iOS

๋ฆด๋ฆฌ์ฆˆ๋ฅผ ๋ชฉํ‘œ๋กœ ํ•˜๋Š” ๋ฏผ์žฌ์ด์ค€ํ˜„๊ทœ์˜ ์œผ๋ผ์ฐจ์ฐจ๐Ÿฆพ ๋Œ€์†Œ๋™๐Ÿงจ iOSโค๏ธ‍๐Ÿ”ฅ TeamNADA. Contribute to TeamNADA/NADA-iOS-ForRelease development by creating an account on GitHub.

github.com

 

728x90
๋ฐ˜์‘ํ˜•
๋Œ“๊ธ€
์ตœ๊ทผ์— ์˜ฌ๋ผ์˜จ ๊ธ€
์ตœ๊ทผ์— ๋‹ฌ๋ฆฐ ๋Œ“๊ธ€
๊ธ€ ๋ณด๊ด€ํ•จ
ยซ   2024/11   ยป
์ผ ์›” ํ™” ์ˆ˜ ๋ชฉ ๊ธˆ ํ† 
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
๋งํฌ
Total
Today
Yesterday