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 主屏幕这样的图标网格?


基础教程推荐
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01