NSString *name = nil;

if (_payNumber == 1) {

name = [NSString stringWithFormat:@"向%@收款",nameStr];

}else if (_payNumber == 2){

name = [NSString stringWithFormat:@"向%@付款",nameStr];

}

//富文本

NSMutableAttributedString *abs = [[NSMutableAttributedString alloc] initWithString:name];

shopNameLabel = [[UILabel alloc] init];

shopNameLabel.font = [UIFont systemFontOfSize:17];

shopNameLabel.textColor = [UIColor colorWithHexString:@"#666666"];

//字体加粗

[abs addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:17.0] range:NSMakeRange(1, nameStr.length)];

//颜色

[abs addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#333333"] range:NSMakeRange(1, nameStr.length)];

shopNameLabel.attributedText = abs;

[shopNameLabel sizeToFit];     //取shopNameLabel.frame.size.width

shopNameLabel.frame = CGRectMake((self.view.frame.size.width - shopNameLabel.frame.size.width)/ 2, shopLogoImg.frame.size.height + shopLogoImg.frame.origin.y + 15, shopNameLabel.frame.size.width, 25);

shopNameLabel.textAlignment = NSTextAlignmentCenter;

[shopInfoView addSubview:shopNameLabel];

iOS富文本的使用的更多相关文章

  1. iOS富文本组件的实现—DTCoreText源码解析 数据篇

    本文转载 http://blog.cnbang.net/tech/2630/ DTCoreText是个开源的iOS富文本组件,它可以解析HTML与CSS最终用CoreText绘制出来,通常用于在一些需 ...

  2. iOS富文本

    背景:前些天突然想做一个笔记本功能,一开始,觉得挺简单的呀,一个UITextView,网络缓存也不干了,直接本地NSUserDefault存储,然后完事了,美工,弄几张好看的图片,加几个动画,也就这样 ...

  3. iOS - 富文本AttributedString

    最近项目中用到了图文混排,所以就研究了一下iOS中的富文本,打算把研究的结果分享一下,也是对自己学习的一个总结. 在iOS中或者Mac OS X中怎样才能将一个字符串绘制到屏幕上呢?         ...

  4. OS开发小记:iOS富文本框架DTCoreText在UITableView上的使用

    要在页面中显示自己的布局,比如文字的字体和颜色.图文并排的样式,我们要用iOS SDK的原生UI在app本地搭建,如果一个页面需要在服务器端获取数据的话,我们也要在本地搭建好固定的布局,解析服务器传回 ...

  5. iOS - 富文本

    iOS--NSAttributedString超全属性详解及应用(富文本.图文混排)   ios项目中经常需要显示一些带有特殊样式的文本,比如说带有下划线.删除线.斜体.空心字体.背景色.阴影以及图文 ...

  6. iOS 富文本类库RTLabel

      本文转载至 http://blog.csdn.net/duxinfeng2010/article/details/9004749  本节关于RTLable基本介绍,原文来自 https://git ...

  7. iOS富文本(一)属性化字符串

    概述 iOS一些复杂的文本布局一般都是由底层的Core Text来实现的,直到iOS7苹果发布了Text Kit框架,Text Kit能够很简单实现一些复杂的文本样式以及布局,而Text Kit富文本 ...

  8. iOS富文本-NSAttributedString简单封装

    直接调用系统的写起来比较麻烦,封装一下 因为要简单所以就写类方法 WJAttributeStyle 基类 ) {         ; i < styles.count; i ++) {      ...

  9. ios富文本的简单使用 AttributedString

    富文本,顾名思义就是丰富的文本格式,本文demo使用NSMutableAttributedString //获取富文本 NSMutableAttributedString*attributeStrin ...

随机推荐

  1. ADF_Data Binding系列2_使用URL Service Data Control

    2015-02-16 Created By BaoXinjian

  2. 有关项目上潜在需要的移动端GIS系统源码整理,待后续更新

    GPS Tools For Android 前言: GPS数据在做GIS开发时的一份宝贵的数据,在不侵犯他人隐私的情况下通过互联网的模式收集GPS是成本最为低廉的一种模式. 背景: 现在公司在做一个项 ...

  3. js 字符串截取

    substr方法: text.substr(start[,length]); text:要提取子字符串的字符串或String对象.必选 start:子字符串的起始位置.以0开始索引.必选 length ...

  4. ubuntu14.04配置impala的odbc连接

    cdh hive和impala的odbc驱动 http://www.cloudera.com/downloads.html.html 选择 SLES 11 64-bit下载: http://www.c ...

  5. Chap5: question: 29 - 31

    29. 数组中出现次数超过一半的数字. 方法a. 排序取中       O(nlogn). 方法b. partition 函数分割找中位数     >=O(n). 方法c. 设计数变量,扫描一遍 ...

  6. 19. Palindrome Partitioning && Palindrome Partitioning II (回文分割)

    Palindrome Partitioning Given a string s, partition s such that every substring of the partition is ...

  7. 40. Interleaving String

    Interleaving String Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. Fo ...

  8. Mono addin 学习笔记 1

    Mono Addin是一个开源的插件框架,其主要支持的特性如下: The main features of Mono.Addins are: Supports descriptions of add- ...

  9. C#修改文件夹权限

    using System;using System.Collections.Generic;using System.Linq;using System.Text; using System.Dire ...

  10. Egret版本更新(H5增加版本号)

    由于浏览器缓存问题.在服务器上更新了新的图片等资源以后,客户端并不会下载最新的. 关于浏览器缓存机制,可自行百度. Egret中资源更新解决方案有以下: 一 资源名后增加版本号 二 重写Egret引擎 ...