Problem and Solution Code Snippets
(积累知识,遇到发展,本文仅用于备忘录,不时它需要召回准备)
Problem:
依据String的大小来调整Label的frame。在view中又一次更新views的layout并显示。
Solution Code Snippets:
-(void)updateData
{
self.view.layer.cornerRadius=10.0;
[HYGlobalFunction setTTLabelText:@"二维码内容test" withParent:self.view withTag:1002 withClass:_StoreText_ withLineNum:1 withURL:NO withLeading:0.0];
TTTAttributedLabel_HY *labelView= (TTTAttributedLabel_HY*)[self.view viewWithTag:1001];
[HYGlobalFunction setTTLabelText:self.description withParent:self.view withTag:1001 withClass:_Arial14Color102New_ withLineNum:0 withURL:NO withLeading:1.0];
labelView.delegate=self;
CGRect frame=labelView.frame;
CGFloat height = 0;
if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
height=40 +ceilf([self.description sizeWithFont:[UIFont boldSystemFontOfSize:19] constrainedToSize:CGSizeMake(frame.size.width, CGFLOAT_MAX) lineBreakMode:UILineBreakModeWordWrap].height);
else
height=20 +ceilf([self.description sizeWithFont:[UIFont boldSystemFontOfSize:15] constrainedToSize:CGSizeMake(frame.size.width, CGFLOAT_MAX) lineBreakMode:UILineBreakModeWordWrap].height);
frame=CGRectMake(frame.origin.x, frame.origin.y, frame.size.width, height);
labelView.frame=frame;
self.view.hidden=YES;
[self changeSuperViewToHeight:height];
[self.view setNeedsDisplay];
} -(void)changeSuperViewToHeight:(CGFloat)height{
CGRect oldFrame = self.view.frame;
CGFloat newHeight = 0;
if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad){
newHeight = height+40;
if(newHeight < oldFrame.size.height)
newHeight = oldFrame.size.height;
}else
newHeight = height+20;
CGRect newFrame = CGRectMake(oldFrame.origin.x, CGRectGetMidY(oldFrame)-newHeight/2, oldFrame.size.width, newHeight);
self.view.frame = newFrame;
}
版权声明:本文博客原创文章。博客,未经同意,不得转载。
Problem and Solution Code Snippets的更多相关文章
- Useful code snippets with C++ boost
Useful code snippets with C++ boost Is Punctuation It’s very straight forward to use boost.regex as ...
- Code Snippets 代码片段
Code Snippets 代码片段 1.Title : 代码片段的标题 2.Summary : 代码片段的描述文字 3.Platform : 可以使用代码片段的平台,有IOS/OS X/ ...
- Xcode开发中 Code Snippets Library 的相关用法
当在进行项目的时候,总会遇到很多相同的写法.因此,我们可以使用Code Snippets Library 来进行代码小片段的“封装”: 以Xcode中常用的属性为例: 使用步骤如下: 1.在Xcode ...
- Xcode开发技巧之Code Snippets Library
http://blog.csdn.net/lin1986lin/article/details/21180007 目录(?)[-] 引言 什么是Code Snippets 如何新建Code Snipp ...
- Sublime Text3—Code Snippets(自定义代码片段)
摘要 程序员总是会不断的重复写一些简单的代码片段,为了提高编码效率,我们可以把经常用到的代码保存起来再调用. 平时用sublime安装各种插件,使用Tab键快速补全,便是snippets(可译为代码片 ...
- iOS开发-代码片段(Code Snippets)提高开发效率
简介 在 XCode4 引入了一个新特性,那就是“代码片段(Code Snippets)”.对于一些经常用到的代码,抽象成模板放到 Code Snippets 中,使用的时候就只需要键入快捷键就可以了 ...
- vscode & code snippets
code snippets vscode & code snippets https://github.com/xgqfrms/FEIQA/tree/master/000-xyz/templa ...
- Random Javascript code snippets
MollyPages.org"You were wrong case.To live here is to live." Home Pages / Database / Forms ...
- 原创题目 白银之春 Problem and Solution
白银之春 Solution 比赛用题面.题解.标程和数据生成器都挂在 git@github.com:sun123zxy/spring.git 上. Problem 白银之春 (spring.cpp/. ...
随机推荐
- oracle至mysql该指南的数据模式()任意数据源之间的跨导应用
为了产生的一些资源的库的释放.需要API模块迁移到mysql在,需要引导数据. 试用oracle to mysql工具.当迁移错误不说,如此大量的数据的,有了这样简陋的工具是不太可靠. 意外的发现工具 ...
- Swift - 发送消息(文本,图片,文件等)给微信好友或分享到朋友圈
通过调用微信提供的API接口,我们可以很方便的在应用中发送消息给微信好友,或者分享到朋友圈.在微信开发平台(https://open.weixin.qq.com)里,提供了详细的说明文档和样例.但由于 ...
- Linear Regression(线性回归)(三)—代价函数J(θ)选择的概率解释
(整理自AndrewNG的课件,转载请注明.整理者:华科小涛@http://www.cnblogs.com/hust-ghtao/) 在遇到线性回归问题时,我们总是令.可是我们为什么这样选择代价函数呢 ...
- MSSQL - 用GUID值来完成数据表行标识
地址:http://www.cnblogs.com/huangfr/archive/2012/03/28/2420780.html [Guid] [uniqueidentifier] NOT NULL ...
- MSSQL - 存储过程OutPut返回值
1.存储过程中不使用外部参数. 存储过程: SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ========================== ...
- Twenty Newsgroups Classification任务之二seq2sparse(2)
接上篇,SequenceFileTokenizerMapper的输出文件在/home/mahout/mahout-work-mahout0/20news-vectors/tokenized-docum ...
- javascript实现的可改变滚动方向的无缝滚动
效果图如下: 代码: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:// ...
- protobuf-2.5.0.tar.gz的下载与安装
1.下载 hadoop使用protocol buffer进行通信,须要下载和安装protobuf-2.5.0.tar.gz.因为如今protobuf-2.5.0.tar.gz已经无法在官网https: ...
- 研读asp.net排课功能实现学习笔记
1.datatable.select 方法,返回的是一个datarow数组 DataRow[] drs = dtHBKC.Select("Subject ...
- NetAnalyzer2016使用方法
NetAnalyzer笔记 之 八 NetAnalyzer2016使用方法(2) [创建时间:2016-05-06 22:07:00] NetAnalyzer下载地址 在写本篇的时候,NetAna ...