如何制作iPhone文件夹之类的东西?
我想知道是否有办法可以将我的视图转换为看起来像 iPhone 文件夹。换句话说,我希望我的视图在中间的某个位置分开并显示其下方的视图。这可能吗?
编辑: 根据下面的建议,我可以通过执行以下操作来截取我的应用程序的屏幕截图:
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
但是,不确定如何处理它。
编辑:2 我已经弄清楚如何向我的视图添加一些阴影,这就是我所实现的(裁剪以显示相关部分):
编辑:3
I'm wanting to know if there's a way I can transform my view to look something like iPhone folders. In other words, I want my view to split somewhere in the middle and reveal a view underneath it. Is this possible?
EDIT:
Per the suggestion below, I could take a screenshot of my application by doing this:
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Not sure what to do with this, however.
EDIT:2
I've figured out how to add some shadows to my view, and here's what I've achieved (cropped to show relevant part):
EDIT:3
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
基本的想法是拍一张你当前状态的照片并将其分割到某个地方。然后通过设置新框架来为两个部分设置动画。我不知道如何以编程方式截取屏幕截图,所以我无法提供示例代码...
编辑:嘿嘿,它看起来不太好,但它有效 ^^
您可以取消注释两行
.contentMode
和质量会提高,但在我的情况下,子视图的偏移量为 10px 左右(您可以通过为两个子视图设置背景颜色来看到它)//编辑 2:好的发现了该错误。使用了整个 320x480 屏幕,但必须切断状态栏,因此它应该是 320x460 并且一切都工作得很好;)
the basic thought will be to take a picture of your current state and split it somewhere. Then animate both parts by setting a new frame. I don't know how to take a screenshot programmatically so I can't provide sample code…
EDIT: hey hey it's not looking great but it works ^^
You can uncomment the two
.contentMode
lines and the quality will improve but in my case the subview has an offset of 10px or so (you can see it by setting a background color to both subviews)//EDIT 2: ok found that bug. Had used the whole 320x480 screen, but had to cut off the status bar so it should be 320x460 and all is working great ;)
您可以为每行图标使用单独的视图,而不是拍摄视图快照。您必须做更多的工作来重新定位内容,但是当文件夹打开时,行不会是静态的(换句话说,它们将根据需要不断重新绘制)。
Instead of taking a snapshot of the view, you could use a separate view for each row of icons. You'll have to do a bit more work with repositioning stuff, but the rows won't be static when the folder is open (in other words, they'll keep redrawing as necessary).
我以 relikd 代码为基础,并使其更加动态。
您可以在调用该函数时指定分割位置和方向,我在分割图像中添加了边框。
这意味着我可以这样调用它:
我在更新的 split 函数中使用了这些便利函数:
并且这个枚举:
添加返回正常函数并添加箭头将是一个很好的补充。
I took relikd's code as a base and made it a bit more dynamic.
You can specify split position and direction when calling the function and I added a boarder to the split images.
This means I can call it like this:
I used these conveniance functions in the updated split function:
and this enum:
Adding a return to normaal function and adding the arrow would be a great addition.