// 标签UILable -显示文字
// 1.创建标签
UILabel *lable = [[UILabel alloc] init];
// 2.设置标签的坐标和大小
[lable setFrame:CGRectMake(,, , )];
// 3.标签内容
lable.text = @"";
// 设置字体
lable.font = [UIFont systemFontOfSize:];
// 设置字体颜色
lable.textColor = [UIColor blackColor];
// 设置内容换行
lable.numberOfLines = ;
//设置圆角
lable.layer.cornerRadius = ;
lable.layer.masksToBounds = NO;
// 设置标签内容居中
lable.textAlignment = NSTextAlignmentCenter;
// 设置标签背景
lable.backgroundColor = [UIColor blackColor];
// 加载图片
UIImageView *tempView = [[UIImageView alloc] init];
[tempView setFrame:CGRectMake(, , , )];
tempView.image = [UIImage imageNamed:@"1.png"];
// 4.在当前视图之上加载子视图
[self.view addSubview:lable];
[lable addSubview:tempView];
 #import "ViewController.h"

 @interface ViewController ()
{
NSTimer *timer;
NSInteger length;
}
@property (weak, nonatomic) IBOutlet UILabel *lable; @end @implementation ViewController -(void) lableMove
{
if (self.lable.frame.origin.y>) {
length = -;
}
else if (self.lable.frame.origin.y<)
{
length = ;
}
CGRect rect = self.lable.frame;
rect.origin.y +=length;
self.lable.frame = rect; if (self.lable.frame.origin.y>) {
[timer invalidate];
[self.lable removeFromSuperview];
}
} - (void)viewDidLoad {
[super viewDidLoad];
/*
NSTimeInterval 计时器响应时间间隔
target:计时器的响应者
selector:计时器的响应方法
userInfo:nil
repeats:计时器是否重复响应
*/
length = ;
timer = [NSTimer timerWithTimeInterval:0.1 target:self selector:@selector(lableMove) userInfo:nil repeats:YES]; //将定时器插入runLoop(超级死循环)中
[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];
}

最新文章

  1. 随手记_C#验证码
  2. DockerCon 2016 – 微软带来了什么?
  3. 让ASP.NET5在Jexus上飞呀飞
  4. 创建agsXMPP 自定义packet types
  5. 安装MariaDB和简单配置
  6. Hi, there!
  7. jQuery漂亮图标的垂直导航菜单
  8. 发送http请求get方法
  9. SQL中插入单引号,新增修改删除
  10. Android基础_3 Activity相对布局
  11. C++11的for循环,以及范围Range类的实现
  12. boost在linux下的编译和使用
  13. 可视化zookeeper的事务日志(转)
  14. javascript 判断是否是PC还是手机端
  15. Scrapy使用以及Xpath的一些坑, 再入剁手
  16. 几种TCP连接中出现RST的情况
  17. WPF笔记(2.8 常用的布局属性)——Layout
  18. [Leetcode][Python]26: Remove Duplicates from Sorted Array
  19. 如何验证所做的AIX系统备份是否可用
  20. yii2之GridView小部件

热门文章

  1. Java ftp上传文件方法效率对比
  2. 20145334赵文豪《网络对抗》shellcode注入&amp;Return-to-libc攻击深入
  3. 20165211 2017-2018-2 《Java程序设计》第1周学习总结
  4. noip2015 day1
  5. grep如何结尾匹配
  6. 可持久化fhq-treap学习笔记
  7. [codeWars] - 8kyu的简单复习
  8. Redis Cluster集群
  9. 【译】第1节--- EF Code First 介绍
  10. UVa 10048 噪音恐惧症(Floyd)