36day 新浪微博(CELL时间 来源)

来源:互联网 发布:手机淘宝5.2.8版本 编辑:程序博客网 时间:2024/06/05 18:47

HWStatuePhotosView
1、#pragma mark - 根据图片个数计算 控件的size

#pragma mark - 根据图片个数计算size/** 计算列数、行数,来确定相册的大小*/- (CGSize)sizeWithPicUrlsCount:(long)count{    long maxCols = HWStatuesPhotoMaxClos(count);    CGFloat wh = HWStatuesPhotoWH(maxCols);    //列数    long cols = (count>=maxCols) ? maxCols : count;    CGFloat photoW  = cols*wh +(cols-1)*HWStatuesPhotoMargin;    //行数    long rows = (count+maxCols-1)/maxCols;//此公式也适用于分页的页数计算    CGFloat photoH = rows*wh +(rows-1)*HWStatuesPhotoMargin;    return CGSizeMake(photoW, photoH);}

判断字符串是否以什么结尾

- (BOOL)isGifImage:(NSString *)url{    /**方法一 *///    NSRange range= [url rangeOfString:@".gif"];//    return !(range.length == 0 || range.location == NSNotFound);    /** 方法二*/    return [url hasSuffix:@".gif"];}

3、图片的内容模式

   /**UIViewContentModeScaleToFill,      拉伸填充整个UIImageView(可能会变形)        UIViewContentModeScaleAspectFit,      // contents scaled to fit with fixed aspect. remainder is transparent  按照原来尺寸继续伸缩填充整个UIImageView(不会变形,上下或者左右可能会出现空白部分)        UIViewContentModeScaleAspectFill,     // contents scaled to fill with fixed aspect. some portion of content may be clipped. 按照原来的尺寸进行拉伸填充,但会超出frame。配合属性使用clipsToBounds 进行裁剪(内容会展示不全) 拉伸到高度(W)与UIImageView的高度(W)一样,就停止拉伸。再居中显示-》部分超出frame        UIViewContentModeRedraw,              // redraw on bounds change (calls -setNeedsDisplay)        UIViewContentModeCenter,              // contents remain same size. positioned adjusted.        UIViewContentModeTop,        UIViewContentModeBottom,        UIViewContentModeLeft,        UIViewContentModeRight,        UIViewContentModeTopLeft,        UIViewContentModeTopRight,        UIViewContentModeBottomLeft,        UIViewContentModeBottomRight,         规律:         1.凡是带有Scale单词的模式,图片都会拉伸         2.凡是带有Aspect单词的模式,图片都会保持图片原来的宽高比(图片不会变形)         */        self.contentMode = UIViewContentModeScaleAspectFill;        self.clipsToBounds = YES;//Setting this value to YES causes subviews to be clipped to the bounds of the receiver.

block定义使用,对外部变量引用的规则

/** 知识点:   1>block会在定义那一刻,直接拿到外部的局部变量task的值。以后block中局部变量task的值就固定不变  2>block中 对被————block修饰的变量的一直引用*/  __block UIBackgroundTaskIdentifier task = [application beginBackgroundTaskWithExpirationHandler:^{      // 当申请的后台运行时间已经结束(过期),就会调用这个block      // 赶紧结束任务      [application endBackgroundTask:task];  }];