A.会员标识
1.需求
给vip会员打上会员标识
不同等级的vip会员使用不同的标识
使用橙色作为昵称颜色
 
 
2.思路
返回的user数据中有两个字段
mbrank:int 会员等级
mbtype:int 会员类型,大于2才是会员
 
3.实现
依照之前的做法,在微博内容界面加上一个ImageView作为vip标识
创建相应的frame
 
(1)在user模型加上vip相关字段
 //
// HVWUser.h
// HVWWeibo
//
// Created by hellovoidworld on 15/2/5.
// Copyright (c) 2015年 hellovoidworld. All rights reserved.
// #import <Foundation/Foundation.h> @interface HVWUser : NSObject /** 友好显示名称 */
@property(nonatomic, copy) NSString *name; /** 用户头像地址(中图),50×50像素 */
@property(nonatomic, copy) NSString *profile_image_url; /** 用户昵称 */
@property(nonatomic, copy) NSString *screen_name; /** 会员等级 */
@property(nonatomic, assign) int mbrank; /** 会员类型 */
@property(nonatomic, assign) int mbtype; /** 是否是会员 */
@property(nonatomic, assign, getter=isVip) BOOL vip; @end
 
 
 //
// HVWUser.m
// HVWWeibo
//
// Created by hellovoidworld on 15/2/5.
// Copyright (c) 2015年 hellovoidworld. All rights reserved.
// #import "HVWUser.h" @implementation HVWUser /** 判断是否是会员 */
- (BOOL)isVip {
return self.mbtype > ;
} @end ()加上vip标识的view
// HVWStatusOriginalView.m
/** vip会员标识 */
@property(nonatomic, weak) UIImageView *vipView; /** 代码初始化方法 */
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame]; if (self) { // 初始化子控件开始
... // vip会员
UIImageView *vipView = [[UIImageView alloc] init];
vipView.contentMode = UIViewContentModeCenter;
self.vipView = vipView;
[self addSubview:vipView]; ...
} return self;
} /** 设置frame */
- (void)setOriginalFrame:(HVWStatusOriginalFrame *)originalFrame {
... // vip会员标识
if (user.isVip) {
self.nameLabel.textColor = [UIColor orangeColor];
self.vipView.hidden = NO;
self.vipView.frame = originalFrame.vipFrame;
self.vipView.image = [UIImage imageWithNamed:[NSString stringWithFormat:@"common_icon_membership_level%d", user.mbrank]]; } else { // 注意cell的重用问题,需要回复设置
self.nameLabel.textColor = [UIColor blackColor];
self.vipView.hidden = YES;
} ...
}
 
(3)计算frame
 //  HVWStatusOriginalFrame.m
/** 加载微博数据 */
- (void)setStatus:(HVWStatus *)status {
_status = status; ... // vip会员标识
if (user.isVip) {
CGFloat vipX = CGRectGetMaxX(self.nameFrame) + HVWStatusCellInset;
CGFloat vipY = nameY;
CGFloat vipWidth = nameSize.height;
CGFloat vipHeight = vipWidth;
self.vipFrame = CGRectMake(vipX, vipY, vipWidth, vipHeight);
}
...
}
 

[iOS微博项目 - 4.4] - 会员标识的更多相关文章

  1. [iOS微博项目 - 2.0] - OAuth授权3步

    A.概念      OAUTH协议为用户资源的授权提供了一个安全的.开放而又简易的标准.与以往的授权方式不同之处是OAUTH的授权不会使第三方触及到用户的帐号信息(如用户名与密码),即第三方无需使用用 ...

  2. [iOS微博项目 - 4.6] - 微博配图

    github: https://github.com/hellovoidworld/HVWWeibo A.微博配图 1.需求 显示原创微博.转发微博的缩略图 4张图使用2x2布局,其他使用3x3布局, ...

  3. [iOS微博项目 - 4.0] - 自定义微博cell

    github: https://github.com/hellovoidworld/HVWWeibo A.自定义微博cell基本结构 1.需求 创建自定义cell的雏形 cell包含:内容.工具条 内 ...

  4. [iOS微博项目 - 3.4] - 获取用户信息

    github: https://github.com/hellovoidworld/HVWWeibo   A.获取用户信息 1.需求 获取用户信息并储存 把用户昵称显示在“首页”界面导航栏的标题上   ...

  5. [iOS微博项目 - 3.2] - 发送微博

    github: https://github.com/hellovoidworld/HVWWeibo   A.使用微博API发送微博 1.需求 学习发送微博API 发送文字微博 发送带有图片的微博   ...

  6. [iOS微博项目 - 3.1] - 发微博界面

    github: https://github.com/hellovoidworld/HVWWeibo   A.发微博界面:自定义UITextView 1.需求 用UITextView做一个编写微博的输 ...

  7. [iOS微博项目 - 3.0] - 手动刷新微博

    github: https://github.com/hellovoidworld/HVWWeibo   A.下拉刷新微博 1.需求 在“首页”界面,下拉到一定距离的时候刷新微博数据 刷新数据的时候使 ...

  8. [iOS微博项目 - 2.6] - 获取微博数据

    github: https://github.com/hellovoidworld/HVWWeibo   A.新浪获取微博API 1.读取微博API     2.“statuses/home_time ...

  9. [iOS微博项目 - 2.3] - 用户取消对app的授权

    github: https://github.com/hellovoidworld/HVWWeibo   A.用户取消对app的授权 用户可以在微博网站上取消对某个应用(app)的授权   1.打开& ...

随机推荐

  1. [转]如何为图片添加热点链接?(map + area)

    原文地址:https://www.cnblogs.com/jf-67/p/8135004.html 所谓图片热点链接就是为图片指定一个或多个区域以实现点击跳转到指定的页面.简单来说就是点击某一区域就能 ...

  2. 怎么使用Less/Sass编译工具koala

    怎么使用Less/Sass编译工具koala 如何使用Less/Sass编译工具koala 一.SASS调试插件的方法 如需调试功能,请在编译输出的时候输出debug信息,那样解析的css文件中就会包 ...

  3. ORACLE中DELETE和TRUNCATE的区别

    语法 delete from AA truncate table AA 区别 1.delete from后面可以写条件(也就是where子句,delete from AA where aa.列名 = ...

  4. scala 测试类

    class NetworkUtilTest extends FunSuite with Matchers { test("testIp2Int") { val ip = Netwo ...

  5. Memcache内存分配策略

    一.Memcache内存分配机制 关于这个机制网上有很多解释的,我个人的总结如下. Page为内存分配的最小单位. Memcached的内存分配以page为单位,默认情况下一个page是1M,可以通过 ...

  6. asp.net 正在加载效果实现

    最近研究了下asp.net 正在加载的实现原理,总结了以下实现方法 首先,我们有个div显示内容为正在加载..   当然也可以考虑用图片或者其他的,不过考虑到速度,建议直接文字提示就行,然后设置div ...

  7. php接入域账号登陆代码

    php接入域账号登陆代码       //替换本地登录为AD域用户认证//edit by ZhangJin on 2015-05-23 -START-$dn = $user_account.'@fun ...

  8. 关于对象序列化json 说说

    下面一个json格式图(说一下,json 其实就是js 数组和对象的一种字符串表现形式 var obj=[] 或者var obj={}  ) var json= {} 如下 从图中看 json中有两个 ...

  9. javascript 实现java中的Map

    javascript实现java中的Map,代码是在国外的一个网站上看到的(http://stackoverflow.com/questions/368280/javascript-hashmap-e ...

  10. 第二百七十节,Tornado框架-生成验证码图片,以及验证码结合Session验证

    Tornado框架-生成验证码图片,以及验证码结合Session验证 第一.生成验证码图片  生成验证码图片需要两个必须模块 1.python自带的random(随机模块) 2.Pillow()图像处 ...