调节一个多行Label之间的间隙
来源:互联网 发布:sql语句采用的编写语言 编辑:程序博客网 时间:2024/05/17 22:35
类方法是存放在这个类的元类结构中
类的方法是存放在这个类的元类结构中
yyivarinfo是封装成员变量的
yymethodinfo是封装方法的
yypropertyinfo是封装属性的
yyclassinfo这个类就是对我们常见的类进行一个二度封装OC中我们所有的类都继承自两个基类, NSObject 或者是 NSProxy(至今未还没见过)
因为类方法的效率更高些,所以一般不需要再方法内部访问成员变量的话,写个类方法还是好一些
比如调节一个多行Label之间的//
// ViewController.m
// TestParagraphLabel
//
// Created by colawh on 16/10/30.
// Copyright © 2016年 colawh. All rights reserved.
//
#import "ViewController.h"
#import "ParagraphLabel.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(100, 200, 100, 200)];
label.numberOfLines = 0;
[self.view addSubview:label];
label.text = @"drawRect在以下情况下会被调用、如果在UIView初始化时没有设置rect大小,将直接导致drawRect不被自动调用。drawRect调用是在Controller->loadView, Controller->viewDidLoad 两方法之后掉用的.所以不用担心在控制器中,这些View的drawRect就开始画了.这样可以在控制器中设置一些值给View(如果这些View draw的时候需要用到某些变量值).";
[label sizeToFit];
label.attributedText = [ViewController attributedStringWithString:label.text];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
+ (NSAttributedString *)attributedStringWithString:(NSString *)string{
NSMutableParagraphStyle *paragraph = [[NSMutableParagraphStyle alloc]init];
paragraph.lineSpacing = 50;
NSMutableAttributedString *touchString = [[NSMutableAttributedString alloc]initWithString:string];
[touchString addAttribute:NSParagraphStyleAttributeName value:paragraph range:[string rangeOfString:string]];
return touchString;
}
@end
- 调节一个多行Label之间的间隙
- 解决img之间的间隙
- img之间的间隙问题
- img之间的间隙问题
- WebSphere Portal调整portlet之间的间隙
- GridView和子View之间的间隙
- 去除inline-block之间的间隙
- Div与图片之间的间隙调整
- flex 如何调整控件之间的间隙
- 解决iframe之间的间隙问题
- 消除列表之间的间隙/空白符
- 一个需要避免的InnoDB间隙锁
- css 图片有间隔多个Img标签之间的间隙
- Div CSS布局常见问题:两个层之间的间隙
- img li 元素之间的间隙原因及清除方法
- html布局中图片之间有间隙的解决方案
- ios实现UITableView 之间的圆角和间隙
- 多种去除inline-block元素之间的间隙解决方法详解
- maven的使用教程
- CSAPP第二章-信息的表示和处理
- Oracle数据库语句大全
- 如何在无序数组中寻找两个出现奇数次整数
- 二叉树的5个性质
- 调节一个多行Label之间的间隙
- Tomcat
- WAMPServer集成环境的安装和配置
- 我的liunx学习笔记之ldap网络帐号
- Unity3D 接Android SDK 遇到的坑
- POJ 2761 Feed the dogs 主席树(区间第k大)
- XML-DOM解析1
- LeetCode: Divide Two Integers
- iOS系统网络抓包方法