How do I create a grid of icons like the iPhone home screen?(如何创建像 iPhone 主屏幕这样的图标网格?)
问题描述
我应该如何在 iPhone 上创建类似于 Springboard(主屏幕)的 UI?我想要一个间隔均匀的按钮网格,其中包含可以响应按钮点击的图像.
How should I go about creating a UI similar to the Springboard (home screen) on the iPhone? I'd like a grid of evenly spaced buttons with images where I can respond to the button tap.
UITable 合适吗?我应该使用普通的 UIView 并在 DrawRect 中手动定位图标吗?是否有替代方案可以自动均匀地间隔按钮、允许重新组织并根据 iPhone 方向调整布局?
Is the UITable a good fit? Should I use a plain UIView and position the icons manually in DrawRect? Is there an alternative that will automatically evenly space the buttons, allow reorganization, and adjust the layout according to the iPhone orientation?
我来自 C#/Winforms 背景,现在正在使用 2.2.1 标头在 Open Toolchain 上开始 iPhone 开发.
I come from a C#/Winforms background and am just now starting iPhone development on the Open Toolchain with 2.2.1 headers.
推荐答案
您需要将您的图标(是某种 UIView)添加为跳板"视图的子视图.不需要自定义绘图,UITable 是绝对错误的方法.您只需进行数学运算以正确放置它们(通过设置它们的框架).
You need to add your icons (which are UIViews of some sort) as subviews of your "Springboard" view. No custom drawing needed, and a UITable is thh absolute wrong way to go. You just need to do the math to place them correctly (by setting their frame).
这篇关于如何创建像 iPhone 主屏幕这样的图标网格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何创建像 iPhone 主屏幕这样的图标网格?
基础教程推荐
- iOS - UINavigationController 添加多个正确的项目? 2022-01-01
- navigationItem.backBarButtonItem 不工作?为什么上一个菜单仍然显示为按钮? 2022-01-01
- 为什么姜饼模拟器方向卡在应用程序中? 2022-01-01
- 如何将图像从一项活动发送到另一项活动? 2022-01-01
- UIImage 在开始时不适合 UIScrollView 2022-01-01
- Play 商店的设备兼容性问题 2022-01-01
- Xcode UIView.init(frame:) 只能在主线程中使用 2022-01-01
- 如何比较两个 NSDate:哪个是最近的? 2022-01-01
- Android Volley - 如何动画图像加载? 2022-01-01
- SwiftUI-ScrollViewReader的ScrollTo不滚动 2022-01-01
