牛叉的demoIOSiOS学习笔记

仿“爱鲜蜂”首页(iOS)

2016-11-26  本文已影响387人  minjing_lin

最近在学Swift 3.0,更新慢了点,勿怪哦~~


亦菲女神

先放效果图哦:


BeeQuick_2.gif

正文

这版时间基本上花在了用Masonry布局UICollectionView上,都是些比较基本的,不同的是代码格式更清晰,易于阅读。
下面说些本项目用到的一些可以复用的知识点。

+(UIColor *) hexStringToColor: (NSString *) stringToConvert
{
    NSString *cString = [[stringToConvert stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString];
    // String should be 6 or 8 characters
    
    if ([cString length] < 6) return [UIColor blackColor];
    // strip 0X if it appears
    if ([cString hasPrefix:@"0X"]) cString = [cString substringFromIndex:2];
    if ([cString hasPrefix:@"#"]) cString = [cString substringFromIndex:1];
    if ([cString length] != 6) return [UIColor blackColor];
    
    // Separate into r, g, b substrings
    
    NSRange range;
    range.location = 0;
    range.length = 2;
    NSString *rString = [cString substringWithRange:range];
    range.location = 2;
    NSString *gString = [cString substringWithRange:range];
    range.location = 4;
    NSString *bString = [cString substringWithRange:range];
    // Scan values
    unsigned int r, g, b;
    
    [[NSScanner scannerWithString:rString] scanHexInt:&r];
    [[NSScanner scannerWithString:gString] scanHexInt:&g];
    [[NSScanner scannerWithString:bString] scanHexInt:&b];
    
    return [UIColor colorWithRed:((float) r / 255.0f)
                           green:((float) g / 255.0f)
                            blue:((float) b / 255.0f)
                           alpha:1.0f];
}
 [self.view makeToast:[NSString stringWithFormat:@"  %ld ",tag] duration:1 position:CSToastPositionCenter];
[self setKeyScrollView:self.collectionView scrolOffsetY: 200 options:HYHidenControlOptionTitle];
[self setNavBarBackgroundImage:[UIImage createImageWithColor:COLOR_YELLOW]];

其它的可以看下仿“爱鲜蜂”二级联动(iOS),最新版本已经上传至github,并解决上次遗留的bug,这里就不在重复讲解了。具体请看我的【DEMO】
相互学习,提高iOS开发技术~~
如果您觉得本Demo对您有用,欢迎点star ,谢谢

上一篇下一篇

猜你喜欢

热点阅读