[翻译] 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 ...
随机推荐
- eclipse中explorer显示方式
不知道是不是上面的描述.做个记录 project explorer 项目资源管理器 这个要打开代码目录需要再点开java resources 还会出现deployment Descriptor项目工程 ...
- centos7-默认启动方式改变
在图形界面使用 ctrl+alt+F2切换到dos界面 dos界面 ctrl+alt+F2切换回图形界面 在命令上 输入 init 3 命令 切换到dos界面 输入 init 5命令 切换到图形界面 ...
- Memcached理解笔2---XMemcached&Spring集成
一.Memcached Client简要介绍 Memcached Client目前有3种: Memcached Client for Java SpyMemcached XMemcached 这三种C ...
- JAVA 图像操作辅助类
package util; import java.awt.Component; import java.awt.Image; import java.awt.MediaTracker; import ...
- ruby实现下订单后给客户发送手机序列号
还有半个小时下班,写点今天做的功能,打发打发时间. 两个类,订单类和序列号类. 订单类 class GroupOrder include Mongoid::Document include Mongo ...
- oracle 报错归纳总结
1.ORA-00904 正常情况下是找不到字段(大概率字段名字错了) 还有一种比较特别的情况实在设计DB的时候,字段小写,在sql查询工具自动提示的时候都是大写,造成字段找不到的情况.
- 设计模式学习——抽象工厂模式(Abstract Factory Pattern)
现有一批装备(产品),分为不同的部位(上装.下装)与不同的等级(lv1.lv2).又有不同lv的工厂,只生产对应lv的全套装备. 代码实现上...本次写得比较偷懒,函数实现都写在头文件了.... 有些 ...
- Qt程序Release版出现 类似 QEventLoop: Cannot be used without QApplication 问题的终极解决方案
最近在做Qt程序开发,程序在Debug下跑是没有问题的,发布到Release版本后,出现各种问题: 报各种莫名其妙的错误,类似的错误有: QEventLoop:Cannot be used wit ...
- Spring 、SpringMVC 、Struts2之间的区别
一.Spring与SpringMVC的区别: spring是一个开源框架,是为了解决企业应用程序开发,功能如下: 功能:使用基本的JavaBean代替EJB,并提供了更多的企业应用功能 范围:任何Ja ...
- 阿里云服务器linux主机如何添加swap分区
为什么要添加Swap分区?swap分区,即交换区,作用为:当系统的物理内存不够用的时候,就需要将物理内存中的一部分空间释放出来,以供当前运行的程序使用.那些被释放的空间可能来自一些很长时间没有什么操作 ...