zoukankan      html  css  js  c++  java
  • 新浪微博客户端(24)-计算原创微博配图frame

    DJStatus.h

    #import <Foundation/Foundation.h>
    
    @class DJUser;
    
    /** 微博 */
    @interface DJStatus : NSObject
    
    /** 微博id */
    @property (nonatomic,copy) NSString *idstr;
    /** 微博内容 */
    @property (nonatomic,copy) NSString *text;
    /** 微博关联用户 */
    @property (nonatomic,strong) DJUser *user;
    /** 发布日期 */
    @property (nonatomic,copy) NSString *created_at;
    /** 来源 */
    @property (nonatomic,copy) NSString *source;
    /** 配图 */
    @property (nonatomic,strong) NSArray *pic_urls;
    
    
    @end

    DJStatus.m

    #import "DJStatus.h"
    #import "MJExtension.h"
    #import "DJPhoto.h"
    
    @implementation DJStatus
    
    
    + (NSDictionary *)mj_objectClassInArray {
    
        return @{@"pic_urls":[DJPhoto class]};
    
    }
    
    @end

    DJPhoto.h

    #import <Foundation/Foundation.h>
    
    @interface DJPhoto : NSObject
    
    /** 图片缩略图 */
    @property (nonatomic,copy) NSString *thumbnail_pic;
    
    @end

    DJStatusCellFrame.m

     // 配图
        CGFloat originalH;
        if (self.status.pic_urls.count) { // 有配图
            CGFloat photoX = contentX;
            CGFloat photoY = CGRectGetMaxY(self.contentLabelF) + DJStatusCellMargin;
            CGFloat photoWH = 100;
            self.photoViewF = CGRectMake(photoX, photoY, photoWH, photoWH);
            originalH = CGRectGetMaxY(self.photoViewF) + DJStatusCellMargin;
        } else { // 无配图
            originalH = CGRectGetMaxY(self.contentLabelF) + DJStatusCellMargin;
        }
        

    最终效果:

  • 相关阅读:
    5-4 链表的天然递归结构性质
    java8 Optional 解析
    [leetcode] Unique Binary Search Trees
    [leetcode] Anagrams
    [leetcode] Valid Number
    构造素数表2
    构造素数表1
    整型所占字节
    习题7-8 字符串转换成十进制整数
    习题7-7 字符串替换
  • 原文地址:https://www.cnblogs.com/yongdaimi/p/6052373.html
Copyright © 2011-2022 走看看