我想使用Reeder iPad应用程序使用的几种技术:
具体来说,我想在左侧导航并使用类似的布局。
他们是如何做到的?它只是位于左侧的标准导航控制器吗?项目/缩略图的布局只是一个自定义的表格视图吗? THX。
答案 0 :(得分:0)
它不是标准的导航控制器。您必须创建自己的UIView
,将其自身附加到一边,并将AutoresizingMask
属性设置为UIViewAutoresizingFlexibleHeight
。使用-drawRect:
和-layoutSubviews:
方法,使用您想要的按钮设置视图。根据您想要对自定义视图进行多少抽象,您可以让所有按钮向UIView
发送消息,然后该视图会将这些消息传递给代理。
示例:
@protocol SideNavigationBarDelegate
- (void)didTapButtonAtIndex:(NSUInteger)buttonIndex;
@end
@interface SideNavigationBar : UIView
@property (strong, nonatomic) id<SideNavigationBarDelegate> delegate;
- (id)initWithDelegate:(id<SideNavigationBarDelegate>)aDelegate;
- (void)addButtonWithIcon:(UIImage *)icon;
- (void)removeButtonAtIndex:(NSUInteger)index;
@end
@implementation SideNavigationBar
...
- (id)initWithDelegate:(id<SideNavigationBarDelegate>)aDelegate {
...
[self setDelegate:aDelegate];
[self setAutoresizingMask:UIViewAutoresizingFlexibleHeight];
[self setFrame:CGRectMake(0.0f, 0.0f, 44.0f, [UIScreen mainScreen].bounds.size.height])];
...
}
- (void)addButtonWithIcon:(UIImage *)icon {
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 44.0f, 44.0f)];
UIImageView *iconView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 44.0f, 44.0f)];
[iconView setContentMode:UIViewContentModeScaleAspectFill];
[iconView setImage:icon];
[button addSubview:iconView];
...set the target and action for the button...
[[self buttons] addObject:button];
}
- (void)drawRect:(CGRect)rect { ...draw buttons on view... }
@end
作为自定义表格视图的缩略图(在本例中为网格视图)。不要自己做,请看一下:https://github.com/AlanQuatermain/AQGridView