回答
你必须写你自己的。例如,这里有一个超级简单的例子,告诉你如何隐藏和显示内容。我没有使用图形+/-按钮(而是一个简单的文本按钮),但希望这可以为您提供足够的线索,让您了解如何正确执行此操作。这只是演示了显示文本面板的动画(您可以在此面板上放置图形或其他内容)。
有很多方法可以做到这一点,这太简单了,显然我没有花时间在美学上,但希望它能向你展示一些你可以使用的技巧。我认为关键的技巧就是把东西放到主视图上的UIView上,给它一个零高度,然后动画扩展框架的变化。您也可以移动按钮,更改用于按钮的UIImage等,但您明白了。
// SlideInViewController.m
#import "SlideInViewController.h"
@interface SlideInViewController()
{
UIView *_hiddenPanel;
UIButton *_hideShowButton;
BOOL _panelHidden;
}
@end
@implementation SlideInViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// initialize the flag
_panelHidden = YES;
// create the panel that will be hidden initially (height of zero), but will be revealed when you click on the button
_hiddenPanel = [[UIView alloc] initWithFrame:CGRectMake(0.0, 300.0, self.view.frame.size.width, 0.0)];
_hiddenPanel.clipsToBounds = YES;
[self.view addSubview:_hiddenPanel];
// add the button
_hideShowButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
_hideShowButton.frame = CGRectMake(40.0, 260.0, 40.0, 40.0);
[_hideShowButton setTitle:@"+" forState:UIControlStateNormal];
[_hideShowButton addTarget:self action:@selector(hideShowPanel:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:_hideShowButton];
// now put whatever you want on this hidden panel.
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.frame.size.width, 200.0)];
label.lineBreakMode = UILineBreakModeWordWrap;
label.numberOfLines = 0;
label.text = @"This is a very long label. This is a very long label. This is a very long label. This is a very long label. This is a very long label. This is a very long label. This is a very long label. This is a very long label. This is a very long label. This is a very long label. This is a very long label. This is a very long label. This is a very long label. This is a very long label. This is a very long label. ";
[_hiddenPanel addSubview:label];
// Do any additional setup after loading the view.
}
- (IBAction)hideShowPanel:(id)sender
{
if (_panelHidden)
{
// if the panel was already hidden, let's reveal it (and move/adjust the button accordingly)
[UIView animateWithDuration:1.0 animations:^{
_hideShowButton.frame = CGRectMake(40.0, 60.0, 40.0, 40.0);
[_hideShowButton setTitle:@"-" forState:UIControlStateNormal];
_hiddenPanel.frame = CGRectMake(0.0, 100.0, self.view.frame.size.width, 200.0);
}];
}
else
{
// if the panel was already shown, so now let's hide it again (and move/adjust the button accordingly)
[UIView animateWithDuration:1.0 animations:^{
_hideShowButton.frame = CGRectMake(40.0, 260.0, 40.0, 40.0);
[_hideShowButton setTitle:@"+" forState:UIControlStateNormal];
_hiddenPanel.frame = CGRectMake(0.0, 300.0, self.view.frame.size.width, 0.0);
}];
}
_panelHidden = !_panelHidden;
}
@end
想了很多。我会试试这个。 – user1506299 2012-07-10 10:23:18
@ user1506299如果有效,请告诉我! – Rob 2012-07-10 16:32:27
是的,它工作得很好。非常感谢你。截图见http://sdrv.ms/LawvBx – user1506299 2012-07-12 02:16:56
- 1. 设计---如何做到这一效果?
- 2. 如何做到这一点逐渐悬停效果
- 3. 如何做到这一点?
- 4. 如何做到这一点?
- 5. 如果(this)可见 - 做到这一点
- 6. 悬停功能,做到这一点,如果X有课,做到这一点
- 7. jQuery的,如果低于10做到这一点,否则,如果0做到这一点不工作
- 8. Python的搜索:如何做到这一点有效
- 9. 如何做到这一点的LINQ
- 10. 如何做到这一点的mod_rewrite与
- 11. 需要iPhone卡翻页效果,无法弄清楚如何做到这一点
- 12. 我该如何更有效地做到这一点?
- 13. 如何更有效地做到这一点? (ListAdapter)
- 14. 如何做到这一点?如果其他结构化。 VBS
- 15. DLLImport Int ** - 如何做到这一点,如果它可以完成
- 16. 如何做到这一点自动?
- 17. 如何在Laravel做到这一点5.2
- 18. 如何在Jinja2中做到这一点?
- 19. 如何做到这一点布局?
- 20. 如何做到这一点查询
- 21. 如何在jQuery中做到这一点?
- 22. 如何使用linq做到这一点?
- 23. 如何在haskell中做到这一点?
- 24. 如何使用Thymleaf做到这一点?
- 25. 如何做到这一点重定向?
- 26. iBooks如何做到这一点?
- 27. 如何在CSS中做到这一点
- 28. 注释 - NSArray - 如何做到这一点?
- 29. istringstream - 如何做到这一点?
- 30. [email protected]如何做到这一点?
图片没有什么区别 – 2012-07-10 02:26:32
看起来你连接的图片被阻止了。 – dasblinkenlight 2012-07-10 02:29:42
我无法查看第一张图片;你能否把它上传到别处? – 2012-07-10 02:30:10