iOS项目基本框架

前传

下午闲来无事写了一个项目初始的框架,简单的做了自定义tabbar和NavgationBar,写了一个父类利用cocoapods集成了常用的几个三方框架,不过没有进行在封装后期还会添加内容,适合入门者来学习,大神勿喷.

正题

样式如下图

123.jpg

中间的按钮如果不想要可以到TYTabBar.m中把创建Button的代码注释掉即可,返回按钮也是自定义,利用UIBarButtonItem添加的分类进行定义,抽取出一个类方法

+(instancetype)itemWithImageNamed:(NSString *)imageName  target:(id)target action:(SEL)action
{
    UIButton * btn = [[UIButton alloc]init];
    [btn setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    NSString * highImageName = [imageName stringByAppendingString:@"-click"];
    [btn setImage:[UIImage imageNamed:highImageName] forState:UIControlStateHighlighted];
    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    [btn sizeToFit];
    return [[UIBarButtonItem alloc]initWithCustomView:btn];
}

自定义tabBar也用了当下用的比较多的利用KVC替换系统的tabBar

TYTabBar * tabBar = [[TYTabBar alloc]init];
    [self setValue:tabBar forKey:@"tabBar"];

希望一起参与进来一起进步,一些常用工具类,后期会慢慢添加.

添加启动页的出现动画,最少需要4张图,我比较懒放了2张

    CGSize viewSize = self.window.bounds.size;
    NSString *viewOrientation = @"Portrait";    //横屏请设置成 @"Landscape"
    NSString *launchImage = nil;
//获取系统的UILaunchImage数组
    NSArray* imagesDict = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"UILaunchImages"];
    for (NSDictionary* dict in imagesDict)
    {
        CGSize imageSize = CGSizeFromString(dict[@"UILaunchImageSize"]);
        
        if (CGSizeEqualToSize(imageSize, viewSize) && [viewOrientation isEqualToString:dict[@"UILaunchImageOrientation"]])
        {
            launchImage = dict[@"UILaunchImageName"];
            
        }
    }
    UIImageView *launchView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:launchImage]];
    launchView.frame = self.window.bounds;
    launchView.contentMode = UIViewContentModeScaleAspectFill;
    [self.window addSubview:launchView];
    [UIView animateWithDuration:2.0f
                          delay:0.0f
                        options:UIViewAnimationOptionBeginFromCurrentState
                     animations:^{
                         
                         launchView.alpha = 0.0f;
                         launchView.layer.transform = CATransform3DScale(CATransform3DIdentity, 1.2, 1.2, 1);
                         
                     }
                     completion:^(BOOL finished) {
                         
                         [launchView removeFromSuperview];
                         
                     }];

不多说上代码
git地址,点击下载

你可能感兴趣的:(iOS项目基本框架)