我想创建一个使用UITabBarController的应用程序,类似于Twitter iPhone和iPod touch应用程序中的选项卡(未读消息蓝光标记,滑动箭头可在内容视图之间切换)。
有没有简单的方法可以做到这一点?有任何开源代码吗?
编辑:
我已添加赏金。我正在寻找适用于iOS 4和iOS 5设备的解决方案。
编辑:
我已修改了我的原始代码,并在我的动画代码中添加了以下检查,以适用于iOS 5:
// iOS 5 changes the subview hierarchy
// so we need to check for it here
BOOL isUsingVersionFive = NO;
NSString *reqSysVer = @"5.0";
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending){
//On iOS 5, otherwise use old index
isUsingVersionFive = YES;
}
然后,不再使用以下代码:
CGFloat tabMiddle = CGRectGetMidX([[[[self tabBar] subviews] objectAtIndex:index] frame]);
我使用这个:
CGFloat tabMiddle = CGRectGetMidX([[[[self tabBar] subviews] objectAtIndex:index + (isUsingVersionFive ? 1 : 0)] frame]);
尽管如此,我仍然坚持悬赏,以便在答案中找到有效的解决方法。
[UIView beginAnimation]
和[UIView commitAnimations]
来包装它,以便让它滑动。 - slf