<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>2 布局调整 on 编程那些事儿</title><link>https://before80.github.io/prgms/Swift/SwiftUI/viewlayout/2-LayoutAdjustments/</link><description>Recent content in 2 布局调整 on 编程那些事儿</description><generator>Hugo</generator><language>zh-cn</language><lastBuildDate>Sun, 13 Sep 2026 18:20:56 +0800</lastBuildDate><atom:link href="https://before80.github.io/prgms/Swift/SwiftUI/viewlayout/2-LayoutAdjustments/index.xml" rel="self" type="application/rss+xml"/><item><title>2.1 布局一个简单视图</title><link>https://before80.github.io/prgms/Swift/SwiftUI/viewlayout/2-LayoutAdjustments/2.1-LayingOutASimpleView/</link><pubDate>Sat, 12 Sep 2026 12:47:47 +0800</pubDate><guid>https://before80.github.io/prgms/Swift/SwiftUI/viewlayout/2-LayoutAdjustments/2.1-LayingOutASimpleView/</guid><description>&lt;blockquote&gt;
&lt;p&gt;原文链接: &lt;a href="https://developer.apple.com/documentation/swiftui/laying-out-a-simple-view"&gt;https://developer.apple.com/documentation/swiftui/laying-out-a-simple-view&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1 id="21-布局一个简单视图"&gt;2.1 布局一个简单视图&lt;/h1&gt;
&lt;p&gt;通过调整视图尺寸来创建视图布局。&lt;/p&gt;
&lt;h2 id="Overview"&gt;概述&lt;/h2&gt;
&lt;p&gt;要为视图创建布局，先组合出一个子视图层级。然后，通过配置参数以及添加视图修饰符（例如影响视图框架和内边距的那些）来细化子视图的尺寸与间距。关于如何组合布局，请参阅 &lt;a href="../../1-LayoutFundamentals/1.2-BuildingLayoutsWithStackViews/"&gt;用栈视图构建布局&lt;/a&gt;。&lt;/p&gt;</description></item><item><title>2.2 检查视图布局</title><link>https://before80.github.io/prgms/Swift/SwiftUI/viewlayout/2-LayoutAdjustments/2.2-InspectingViewLayout/</link><pubDate>Sat, 12 Sep 2026 12:47:47 +0800</pubDate><guid>https://before80.github.io/prgms/Swift/SwiftUI/viewlayout/2-LayoutAdjustments/2.2-InspectingViewLayout/</guid><description>&lt;blockquote&gt;
&lt;p&gt;原文链接: &lt;a href="https://developer.apple.com/documentation/swiftui/inspecting-view-layout"&gt;https://developer.apple.com/documentation/swiftui/inspecting-view-layout&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1 id="22-检查视图布局"&gt;2.2 检查视图布局&lt;/h1&gt;
&lt;p&gt;使用 Xcode 预览或添加临时边框来确定视图的位置与范围。&lt;/p&gt;
&lt;h2 id="Overview"&gt;概述&lt;/h2&gt;
&lt;p&gt;要了解 SwiftUI 如何确定视图的尺寸和位置，可以借助 Xcode 预览来检查单个视图的边界。你也可以添加临时边框，看看 SwiftUI 如何一并确定多个视图的位置和尺寸。&lt;/p&gt;</description></item><item><title>2.3 微调视图的位置</title><link>https://before80.github.io/prgms/Swift/SwiftUI/viewlayout/2-LayoutAdjustments/2.3-MakingFineAdjustmentsToAViewSPosition/</link><pubDate>Sat, 12 Sep 2026 12:47:47 +0800</pubDate><guid>https://before80.github.io/prgms/Swift/SwiftUI/viewlayout/2-LayoutAdjustments/2.3-MakingFineAdjustmentsToAViewSPosition/</guid><description>&lt;blockquote&gt;
&lt;p&gt;原文链接: &lt;a href="https://developer.apple.com/documentation/swiftui/making-fine-adjustments-to-a-view-s-position"&gt;https://developer.apple.com/documentation/swiftui/making-fine-adjustments-to-a-view-s-position&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1 id="23-微调视图的位置"&gt;2.3 微调视图的位置&lt;/h1&gt;
&lt;p&gt;通过应用 offset 或 position 修饰符来移动视图的位置。&lt;/p&gt;
&lt;h2 id="Overview"&gt;概述&lt;/h2&gt;
&lt;p&gt;使用 SwiftUI 以自适应方式排布和定位你的视图。如果仅靠组合无法实现你的设计，就用视图修饰符微调布局。添加 offset 修饰符可以把视图的渲染内容从其当前位置移开，或者添加 position 修饰符来在其父视图内设置一个显式位置。&lt;/p&gt;</description></item><item><title>2.4 在栈内对齐视图</title><link>https://before80.github.io/prgms/Swift/SwiftUI/viewlayout/2-LayoutAdjustments/2.4-AligningViewsWithinAStack/</link><pubDate>Sat, 12 Sep 2026 12:47:47 +0800</pubDate><guid>https://before80.github.io/prgms/Swift/SwiftUI/viewlayout/2-LayoutAdjustments/2.4-AligningViewsWithinAStack/</guid><description>&lt;blockquote&gt;
&lt;p&gt;原文链接: &lt;a href="https://developer.apple.com/documentation/swiftui/aligning-views-within-a-stack"&gt;https://developer.apple.com/documentation/swiftui/aligning-views-within-a-stack&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1 id="24-在栈内对齐视图"&gt;2.4 在栈内对齐视图&lt;/h1&gt;
&lt;p&gt;使用对齐参考线在栈内定位视图。&lt;/p&gt;
&lt;h2 id="Overview"&gt;概述&lt;/h2&gt;
&lt;p&gt;栈按其对齐方式放置子视图，默认采用居中对齐。在初始化栈时，你可以为栈指定一种对齐方式，它同样会作用于栈的子视图。如果你想修改单个子视图的位置，请使用 alignment guide 修饰符做出调整，使视图相对于栈提供的对齐方式产生偏移。&lt;/p&gt;</description></item><item><title>2.5 跨栈对齐视图</title><link>https://before80.github.io/prgms/Swift/SwiftUI/viewlayout/2-LayoutAdjustments/2.5-AligningViewsAcrossStacks/</link><pubDate>Sat, 12 Sep 2026 12:47:47 +0800</pubDate><guid>https://before80.github.io/prgms/Swift/SwiftUI/viewlayout/2-LayoutAdjustments/2.5-AligningViewsAcrossStacks/</guid><description>&lt;blockquote&gt;
&lt;p&gt;原文链接: &lt;a href="https://developer.apple.com/documentation/swiftui/aligning-views-across-stacks"&gt;https://developer.apple.com/documentation/swiftui/aligning-views-across-stacks&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1 id="25-跨栈对齐视图"&gt;2.5 跨栈对齐视图&lt;/h1&gt;
&lt;p&gt;创建自定义对齐方式，并用它在多个栈之间对齐视图。&lt;/p&gt;
&lt;h2 id="Overview"&gt;概述&lt;/h2&gt;
&lt;p&gt;当你把多个栈嵌套在一起时，可能希望这些栈中的某些特定项目彼此对齐。默认情况下，你为某个栈指定的对齐方式只作用于该栈的子视图。要让位于嵌套栈中的子视图彼此对齐，请定义一种自定义对齐方式，把它指定给外层视图，并使用 alignment guide 修饰符来标识需要对齐的特定视图。&lt;/p&gt;</description></item><item><title>2.6 ExpressibleByFloatLiteral 实现</title><link>https://before80.github.io/prgms/Swift/SwiftUI/viewlayout/2-LayoutAdjustments/2.6-ExpressiblebyfloatliteralImplementations/</link><pubDate>Sat, 12 Sep 2026 12:47:47 +0800</pubDate><guid>https://before80.github.io/prgms/Swift/SwiftUI/viewlayout/2-LayoutAdjustments/2.6-ExpressiblebyfloatliteralImplementations/</guid><description>&lt;blockquote&gt;
&lt;p&gt;原文链接: &lt;a href="https://developer.apple.com/documentation/swiftui/edge/corner/style/expressiblebyfloatliteral-implementations"&gt;https://developer.apple.com/documentation/swiftui/edge/corner/style/expressiblebyfloatliteral-implementations&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1 id="26-expressiblebyfloatliteral-实现"&gt;2.6 ExpressibleByFloatLiteral 实现&lt;/h1&gt;
&lt;h2 id="Initializers"&gt;初始化器&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.apple.com/documentation/swiftui/edge/corner/style/init(floatliteral:)"&gt;init(floatLiteral:)&lt;/a&gt; — 以浮点值作为圆角半径创建固定的圆角样式。这是书写 &lt;code&gt;.fixed(value)&lt;/code&gt; 的简写。&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>2.7 ExpressibleByIntegerLiteral 实现</title><link>https://before80.github.io/prgms/Swift/SwiftUI/viewlayout/2-LayoutAdjustments/2.7-ExpressiblebyintegerliteralImplementations/</link><pubDate>Sat, 12 Sep 2026 12:47:47 +0800</pubDate><guid>https://before80.github.io/prgms/Swift/SwiftUI/viewlayout/2-LayoutAdjustments/2.7-ExpressiblebyintegerliteralImplementations/</guid><description>&lt;blockquote&gt;
&lt;p&gt;原文链接: &lt;a href="https://developer.apple.com/documentation/swiftui/edge/corner/style/expressiblebyintegerliteral-implementations"&gt;https://developer.apple.com/documentation/swiftui/edge/corner/style/expressiblebyintegerliteral-implementations&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1 id="27-expressiblebyintegerliteral-实现"&gt;2.7 ExpressibleByIntegerLiteral 实现&lt;/h1&gt;
&lt;h2 id="Initializers"&gt;初始化器&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.apple.com/documentation/swiftui/edge/corner/style/init(integerliteral:)"&gt;init(integerLiteral:)&lt;/a&gt; — 以整数值作为圆角半径创建固定的圆角样式。这是书写 &lt;code&gt;.fixed(value)&lt;/code&gt; 的简写。&lt;/li&gt;
&lt;/ul&gt;</description></item></channel></rss>