1 IDSGenderLeviNamedView 的实现效果
 
 
2 类的封装方法:
 
IDSGenderLeviNamedView.h
 
@interface IDSGenderLeviNamedView : UIView
 
@property (nonatomic, strong) UILabel *ageLabel;
 
@property (nonatomic, strong) UIImageView *genderImageView;
 
- (instancetype)initWithGender:(NSInteger)gender age:(NSInteger)age;
 
- (void)gender:(NSInteger)gender age:(NSInteger)age;
 
@end
 
IDSGenderLeviNamedView.m
 
#import "IDSGenderLeviNamedView.h"
 
@implementation IDSGenderLeviNamedView
 
#pragma mark - 初始化需求函数
 
- (instancetype)initWithGender:(NSInteger)gender age:(NSInteger)age
{
    if (self = [superinit]) {
        self.genderImageView = [[UIImageViewalloc] initWithFrame:CGRectMake(3, 2, 10, 10)];
        if (gender == 0) {
            self.genderImageView.image = IDSImageNamed(@"img_yiqiwan_man");
            self.backgroundColor = NF_Color_C32;
        }
        else {
            self.genderImageView.image = IDSImageNamed(@"img_yiqiwan_woman");
            self.backgroundColor = NF_Color_C30;
        }
        self.genderImageView.contentMode = UIViewContentModeScaleAspectFill;
        [selfaddSubview:self.genderImageView];
        self.ageLabel = [[UILabelalloc] init];
        self.ageLabel.font = [UIFontsystemFontOfSize:Near_Final_Font_T1];
        self.ageLabel.textColor = NF_Color_C1;
        if (age) {
            self.ageLabel.text = [NSStringstringWithFormat:@"%ld",age];
            self.ageLabel.frame = CGRectMake(CGRectGetMaxX(self.genderImageView.frame)+1, 0, 0, 0);
            self.ageLabel.font = [UIFontsystemFontOfSize:Near_Final_Font_T1];
            self.ageLabel.textColor = NF_Color_C1;
            [self.ageLabelsizeToFit];
            self.ageLabel.centerY = self.genderImageView.centerY;//测试一下可行不?
            [selfaddSubview:self.ageLabel];
            self.frame = CGRectMake(0, 0, CGRectGetMaxX(self.ageLabel.frame)+3, 14);
        }
        else {
            self.frame = CGRectMake(0, 0, CGRectGetMaxX(self.genderImageView.frame)+3, 14);
        }
       
        self.layer.cornerRadius = 3.0f;
        self.layer.masksToBounds = YES;
        self.clipsToBounds = YES;
    }
    returnself;
}
 
- (void)gender:(NSInteger)gender age:(NSInteger)age
{
    self.genderImageView.frame = CGRectMake(3, 2, 10, 10);
    if (gender == 0) {
        self.genderImageView.image = IDSImageNamed(@"img_yiqiwan_man");
        self.backgroundColor = NF_Color_C32;
    }
    else {
        self.genderImageView.image = IDSImageNamed(@"img_yiqiwan_woman");
        self.backgroundColor = NF_Color_C30;
    }
    self.genderImageView.contentMode = UIViewContentModeScaleAspectFill;
   
    self.ageLabel.font = [UIFontsystemFontOfSize:Near_Final_Font_T1];
    self.ageLabel.textColor = NF_Color_C1;
    if (age) {
        self.ageLabel.hidden = NO;
        self.ageLabel.text = [NSStringstringWithFormat:@"%ld",age];
        self.ageLabel.frame = CGRectMake(CGRectGetMaxX(self.genderImageView.frame)+1, 0, 0, 0);
        self.ageLabel.font = [UIFontsystemFontOfSize:Near_Final_Font_T1];
        self.ageLabel.textColor = NF_Color_C1;
        [self.ageLabelsizeToFit];
        self.ageLabel.centerY = self.genderImageView.centerY;//测试一下可行不?
        self.frame = CGRectMake(0, 0, CGRectGetMaxX(self.ageLabel.frame)+3, 14);
    }
    else {
        self.ageLabel.hidden = YES;
        self.frame = CGRectMake(0, 0, CGRectGetMaxX(self.genderImageView.frame)+3, 14);
    }
   
    self.layer.cornerRadius = 3.0f;
    self.layer.masksToBounds = YES;
    self.clipsToBounds = YES;
}
 
@end
 
 
- OVER

性别年龄的模块封装类 IDSGenderLeviNamedView的更多相关文章

  1. [Audio processing] 数据集生成 & 性别年龄分类训练 Python

    1.重命名,Python中文路径各种错误,所以需要先将所有文件的路径名全都改成中文.用的是MAC系统,所以WIN下的命令行批处理没法解决,所以用C来完成 // Created by Carl on 1 ...

  2. 星星的模块封装类 IDSStarsScoreView

    1 IDSStarsScoreView 的实现效果     2 类的封装方法:   <声明文件>   // //  IDSStarsScoreView.h //  Near // //  ...

  3. 基于安卓高仿how-old.net实现人脸识别估算年龄与性别

    前几段微软推出的大数据人脸识别年龄应用how-old.net在微博火了一把,它可以通过照片快速获得照片上人物的年龄,系统会对瞳孔.眼角.鼻子等27个“面部地标点"展开分析,进而得出你的“颜龄 ...

  4. 虚基类——(1)定义人员类Person: 公有成员:姓名(Name); 保护成员:性别(Gender),年龄(Age); 构造函数和析构函数

    题目描述: (1)定义人员类Person: 公有成员:姓名(Name): 保护成员:性别(Gender),年龄(Age): 构造函数和析构函数 (2) 从人员类Person派生学生记录类Student ...

  5. 内置函数 hashlib configparser logging 模块 C/S B/S架构

    1.内置函数 # 内置的方法有很多 # 不一定全都在object中 # class Classes: # def __init__(self,name): # self.name = name # s ...

  6. 常用模块 - openpyxl模块

    一.简介 xlrd/xlwt 主要是针对Office 2003或更早版本的XLS文件格式 缺点:不支持XLSX文件格式 OpenPyXL 能读能写能修改 缺点:不支持XLS Microsoft Exc ...

  7. python----openpyxl模块

    openpyxl 模块 1.openpyxl的写 from openpyxl import Workbook wb = Workbook() # 方式一: 默认创建sheet在最后 wb1 = wb. ...

  8. python面向编程: 常用模块补充与面向对象

    一.常用模块 1.模块 的用用法 模块的相互导入 绝对导入 从sys.path (项目根目录)开始的完整路径 相对导入 是指相对于当前正在执行的文件开始的路径 只能用于包内模块相互间导入 不能超过顶层 ...

  9. 操作excel--xlwt/xlrd/xlutils模块

    一.写Excel (导入xlwt模块)需求:只要你传入一个表名,就能把所有的数据导入出来写入excel,字段名是excel的表头分析: 1.要动态获取到表的字段 cur.description能获取到 ...

随机推荐

  1. hadoop 3.x org.apache.hadoop.security.AccessControlException: Permission denied: user=Administrator, access=WRITE, inode="/":tele:supergroup:drwxr-xr-x

    权限不足,上传文件时应当使用启动hadoop的账户,即在获取FileSystem时就应当指定用户 修改后的代码 public class Demo1 { public static void main ...

  2. SQL基础问题整理

    在程序中,数据库操作是必不可少的部分,所以我们要备足数据库相关知识才能去应付程序中出现的种种问题.基于此,我特地在国外网站.博客上整理了一些问题,并附带了答案和解释.参考.为了保证“原汁原味”,我就保 ...

  3. 如何在spring quartz类中拿到ServletContext

    ContextLoader.getCurrentWebApplicationContext().getServletContext() web.xml里加个: <listener> < ...

  4. 保护SSD,设置Chrome浏览器临时文件夹到ramdisk分区

    很多用低端/山寨SSD的朋友都用Ramdisk来保护硬盘,一般都把系统temp目录和IE浏览器临时文件夹目录设到Ramdisk分区了.      最近用谷歌的chrome浏览器,发现浏览网页时候硬盘灯 ...

  5. 获取web.config配置文件的sectionGroup

    1)web.config 文件内容如下: <configuration> <configSections> <sectionGroup name="KaiXin ...

  6. poj 3071 可能DP

    http://poj.org/problem? id=3071 推方程不难,可是难在怎么算 dp[i][j]表示第i场时第j仅仅队伍存活下来的概率 方程:dp[i][j]=sigma(dp[i-1][ ...

  7. CUDA+OpenGL混合编程

    CUDA+OpenGL混合编程示例: #include <stdio.h> #include <stdlib.h> #include "GL\glew.h" ...

  8. UVA 1347(POJ 2677) Tour(双色欧几里德旅行商问题)

    Description John Doe, a skilled pilot, enjoys traveling. While on vacation, he rents a small plane a ...

  9. Linux经常使用的命令(21) - find参数具体解释

    一.使用name选项: 文件名称选项是find命令最经常使用的选项.要么单独使用该选项,要么和其它选项一起使用.  能够使用某种文件名称模式来匹配文件,记住要用引號将文件名称模式引起来.  无论当前路 ...

  10. 如何获得 Qt窗口部件在主窗口中的位置--确定鼠标是否在某一控件上与在控件上的位置

    用Qt Creator 设计程序时,最方便的就是ui设计器,可以很容易的得到想要的布局. 但是这样自动布局带来的后果是很难知道窗口中某一部件在主窗口中的相对位置. 在处理子窗口鼠标事件时变的很麻烦.主 ...