[翻译] UIImageView-Letters
UIImageView-Letters

https://github.com/bachonk/UIImageView-Letters

An easy, helpful UIImageView category that generates letter initials as a placeholder for user profile images, with a randomized background color
一个简单,易用的,根据用户的英文名字生成了一个placeholder文件,并随机赋上一种颜色
Usage
In the file where you want to use the category, be sure to import the file.
#import "UIImageView+Letters.h"
在你想用的地方,引入头文件即可
Methods 方法
Call the following methods on any UIImageView instance to set the image:
你可以给UIImageView调用如下两种方法:
- (void)setImageWithString:(NSString *)string- (void)setImageWithString:(NSString *)string color:(UIColor *)color
string is the string used to generate the initials. This should be a user's full name if available.
string是用来产生缩写的,当然,这个得需要是用户合法的全名。
color is an optional parameter that sets the background color of the image. Pass in nil to have a color automatically generated for you.
颜色是备选参数,用来设置图片背景色的。如果你传递了nil值,他会给你随机产生一种颜色。
Example 使用示例
NSString *userName = @"Michael Bluth";
UIImageView *myImgView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 50, 50)];
[myImgView setImageWithString:userName];
以下附上本人的使用教程:
//
// RootViewController.m
// Letter
//
// Created by YouXianMing on 14-9-13.
// Copyright (c) 2014年 YouXianMing. All rights reserved.
// #import "RootViewController.h"
#import "UIImageView+Letters.h" @interface RootViewController () @end @implementation RootViewController - (void)viewDidLoad
{
[super viewDidLoad]; NSArray *nameArray = @[@"Michael Bluth", @"You Xian", @"Jim Simith",
@"Li Dian", @"Jun Gang", @"You Jin",
@"Lin Ken", @"Li kui", @"Leter Jun"]; for (int i = ; i < nameArray.count; i++)
{
NSString *userName = nameArray[i];
UIImageView *myImgView = \
[[UIImageView alloc] initWithFrame:CGRectMake( + (i%)*, // 求余
+ (i/)*, // 取整
, )];
myImgView.layer.cornerRadius = .f;
myImgView.layer.masksToBounds = YES;
[myImgView setImageWithString:userName];
[self.view addSubview:myImgView];
}
} @end

再来看看人家的源码:


[翻译] UIImageView-Letters的更多相关文章
- [翻译]AKKA笔记 -ACTOR SUPERVISION - 8
失败更像是分布式系统的一个特性.因此Akka用一个容忍失败的模型,在你的业务逻辑与失败处理逻辑(supervision逻辑)中间你能有一个清晰的边界.只需要一点点工作,这很赞.这就是我们要讨论的主题. ...
- StackOverFlow排错翻译 - Python字符串替换: How do I replace everything between two strings without replacing the strings?
StackOverFlow排错翻译 - Python字符串替换: How do I replace everything between two strings without replacing t ...
- (翻译)开始iOS 7中自动布局教程(二)
这篇教程的前半部分被翻译出来很久了,我也是通过这个教程学会的IOS自动布局.但是后半部分(即本篇)一直未有翻译,正好最近跳坑翻译,就寻来这篇教程,进行翻译.前半部分已经转载至本博客,后半部分即本篇.学 ...
- 《Entity Framework 6 Recipes》中文翻译系列 (30) ------ 第六章 继承与建模高级应用之多对多关联
翻译的初衷以及为什么选择<Entity Framework 6 Recipes>来学习,请看本系列开篇 第六章 继承与建模高级应用 现在,你应该对实体框架中基本的建模有了一定的了解,本章 ...
- poj 2503:Babelfish(字典树,经典题,字典翻译)
Babelfish Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 30816 Accepted: 13283 Descr ...
- AFNetworking2.0 NSHipster翻译
AFNetworking 是当前 iOS 和 Mac OS X 开发中最广泛使用的开源项目之一.它帮助了成千上万叫好又叫座的应用,也为其它出色的开源库提供了基础.这个项目是社区里最活跃.最有影响力的项 ...
- PEP8中文翻译(转)
原文:https://github.com/zgia/manual PEP 8 -- Style Guide for Python Code PEP Index > PEP 8 -- Style ...
- face recognition[翻译][深度人脸识别:综述]
这里翻译下<Deep face recognition: a survey v4>. 1 引言 由于它的非侵入性和自然特征,人脸识别已经成为身份识别中重要的生物认证技术,也已经应用到许多领 ...
- UnicodeMath数学公式编码_翻译(Unicode Nearly Plain - Text Encoding of Mathematics Version 3)
目录 完整目录 1. 简介 2. 编码简单数学表达式 2.1 分数 2.2 上标和下标 2.3 空白(空格)字符使用 3. 编码其他数学表达式 3.1 分隔符 强烈推荐本文简明版UnicodeMath ...
随机推荐
- mysql修改存储过程的权限
直接上代码 grant execute on procedure 表名.存储过程名(eg: student.find) to '用户名'@'host'(eg: 'volumelicense'@'%') ...
- iOS 微信支付SDK与微信友盟分享两者同时集成时,出现的问题与解决之路。
这两天改版一个旧的APP,要旧貌换新颜,拿到app后进行编译,一直报下面的错误. 报不认识的符号名PayReq错误.奇怪,啥也没动就这样,真不知道给的包是不是本来就是个报错的工程. 不管怎样,要对它修 ...
- 使用gitlab, jenkins搭建CI(持续集成)系统(2) -- 配置webhook触发构建
1. 在gitlab上配置192.168.1.30的ssh秘钥,使jenkins可以操作gitlab上的project 进入gitlab,点击右上角 点击 Settings -> SSH key ...
- bind9配置转发服务
修改bind主配置文件 $ vi /etc/named.conf//// named.conf//// Provided by Red Hat bind package to configure th ...
- HttpContext概念讲解
一:HttpContext理论知识: 1:HttpContext类它对Request.Respose.Server等等都进行了封装,并保证在整个请求周期内都可以随时随地的调用:为继承 IHttpMod ...
- 针对Eclipse闪退的两种解决方案
闪退情况是:双击Eclipse登陆按钮,显示图标后,紧接着关闭: 1. 到eclipse文件夹中的eclipse.ini打开编辑在最后加入下面代码保存即可 -Dorg.eclipse.swt.brow ...
- JAVA 项目 调用外部的WebSerivce接口,入门实例 (一)
前言: 第一次接触WebService,工作需要,调用外部的WebService接口,所以暂时我这里不考虑发布,做个记录,待以后回来可以看看,只是最初级的,所以有何不好.不对的地方,欢迎看到的同僚给予 ...
- 一次线上OOM过程的排查
https://blog.csdn.net/qq_16681169/article/details/53296137 一.出现问题 在前一段时间日常环境很不稳定,前端调用mtop接口会出网络异常或服务 ...
- python 历险记(五)— python 中的模块
目录 前言 基础 模块化程序设计 模块化有哪些好处? 什么是 python 中的模块? 引入模块有几种方式? 模块的查找顺序 模块中包含执行语句的情况 用 dir() 函数来窥探模块 python 的 ...
- 使用EXCEL 完成分组统计
表testTable 有以下数据,要统计各个电视剧的数量.在开发人员看来,使用sql操作完成select name,count(*) from TestTable where 1=1 group by ...