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 主屏幕这样的图标网格?
基础教程推荐
- 在 appComponent dagger 2 中动态添加测试模块? 2022-01-01
- 如何将多个组件添加到 PickerView? 2022-01-01
- 在 iOS8 中无法获得正确的键盘高度值 2022-01-01
- - (CGRect)convertRect:(CGRect)rect toView:(UIView *)view 如何工作 2022-01-01
- 在 Android 模拟器中激活网络位置提供程序? 2022-01-01
- 可可/目标C(OSX不是iOS)从子对象访问父对象 2022-01-01
- 新的@SystemApi 注解是什么意思,和@hide 有什么区别 2022-01-01
- 突出显示朗读文本(在 iPhone 的故事书类型应用程序中) 2022-01-01
- Android:STATE_SELECTED不工作 2022-01-01
- 我的 UIImageView 的任务 2022-01-01
