山寨今日头条的标题title效果

效果:

源码:

//
// ViewController.m
// 今日头条
//
// Created by YouXianMing on 14/11/26.
// Copyright (c) 2014年 YouXianMing. All rights reserved.
// #import "ViewController.h" @interface ViewController ()<UIScrollViewDelegate>
@property (nonatomic, strong) UIScrollView *scrollView;
@property (nonatomic, strong) UIView *alphaView;
@end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad]; [self.view addSubview:[self theSubView]];
[self.view addSubview:[self theFrontView]]; self.scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
self.scrollView.delegate = self;
self.scrollView.pagingEnabled = YES;
self.scrollView.contentSize = CGSizeMake(self.scrollView.bounds.size.width * ,
self.scrollView.bounds.size.height);
[self.view addSubview:self.scrollView];
} - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
CGRect rect = self.alphaView.frame;
rect.origin.x = scrollView.contentOffset.x / .f;
self.alphaView.frame = rect;
} - (UIView *)theSubView {
// 添加前景色
UIView *backView = [[UIView alloc] initWithFrame:CGRectMake(, , , )];
backView.backgroundColor = [UIColor colorWithRed:0.922 green:0.922 blue:0.922 alpha:];
[self.view addSubview:backView]; // 标题1
UILabel *title1 = [[UILabel alloc] initWithFrame:CGRectMake(, , , )];
title1.text = @"今日头条";
title1.textAlignment = NSTextAlignmentCenter;
title1.font = [UIFont systemFontOfSize:.f];
title1.textColor = [UIColor colorWithRed:0.443 green:0.439 blue:0.439 alpha:];
[backView addSubview:title1]; // 标题2
UILabel *title2 = [[UILabel alloc] initWithFrame:CGRectMake(, , , )];
title2.text = @"YouXianMing";
title2.textAlignment = NSTextAlignmentCenter;
title2.font = [UIFont systemFontOfSize:.f];
title2.textColor = [UIColor colorWithRed:0.443 green:0.439 blue:0.439 alpha:];
[backView addSubview:title2]; return backView;
} - (UIView *)theFrontView {
// 添加前景色
UIView *backView = [[UIView alloc] initWithFrame:CGRectMake(, , , )];
backView.backgroundColor = [UIColor colorWithRed:0.808 green:0.208 blue:0.212 alpha:];
[self.view addSubview:backView]; // 标题1
UILabel *title1 = [[UILabel alloc] initWithFrame:CGRectMake(, , , )];
title1.text = @"今日头条";
title1.textAlignment = NSTextAlignmentCenter;
title1.font = [UIFont systemFontOfSize:.f];
title1.textColor = [UIColor colorWithRed:0.945 green:0.827 blue:0.827 alpha:];
[backView addSubview:title1]; // 标题2
UILabel *title2 = [[UILabel alloc] initWithFrame:CGRectMake(, , , )];
title2.text = @"YouXianMing";
title2.textAlignment = NSTextAlignmentCenter;
title2.font = [UIFont systemFontOfSize:.f];
title2.textColor = [UIColor colorWithRed:0.945 green:0.827 blue:0.827 alpha:];
[backView addSubview:title2]; self.alphaView = [[UIView alloc] initWithFrame:CGRectMake(, , , )];
self.alphaView.backgroundColor = [UIColor blackColor];
self.alphaView.layer.cornerRadius = .f;
backView.maskView = self.alphaView; return backView;
} @end

图片:

一切尽在不言中:)

最新文章

  1. make: *** [out/host/linux-x86/obj/EXECUTABLES/obbtool_intermediates/Main.o] Error 1
  2. PHP memcache 安装问题
  3. chrome编辑DOM
  4. 使用Apriori算法和FP-growth算法进行关联分析
  5. SpringMVC+Spring3+hibernate4 开发环境搭建以及一个开发实例教程
  6. iOS开发 落地消息多的处理办法(仅供参考)
  7. 为MVC 添加下载权限
  8. openssl之EVP系列之1---算法封装
  9. eclipse3.2 汉化 汉化包下载
  10. 转 如何不耍流氓的做运维之——SHELL脚本
  11. C#之out修饰符、ref修饰符、params修饰符的简单介绍
  12. Angular4基本网络请求get、post方式
  13. IntellJ IDEA下写JUnit
  14. 6. 从Encoder-Decoder(Seq2Seq)理解Attention的本质
  15. 【Big Data - ELK】ELK(ElasticSearch, Logstash, Kibana)搭建实时日志分析平台
  16. js判断手机是安卓还是ios
  17. AngularJS 的常用特性(五)
  18. 细说React(一)
  19. Python3 计算城市距离
  20. POJ1985 树的直径(BFS

热门文章

  1. JS浮点数精确计算方法
  2. xgb 绘制
  3. elasticsearch插件安装之--中文分词器 ik 安装
  4. Nodejs学习笔记(十二)—定时任务(node-schedule)
  5. 软件级负载均衡器(LVS/HAProxy/Nginx)的特点简介和对比
  6. C#中的序列化和反序列化是什么、有什么作用、使用方法详解
  7. c#基础学习(0806)之StringBuilder的使用
  8. unity 中的协程
  9. Error: EACCES: permission denied, access &#39;/usr/local/lib/node_modules&#39;
  10. iOS交互h5— JavaScriptCore ---UIWebview