山寨凤凰新闻菜单效果
山寨凤凰新闻菜单效果
效果图:
山寨来源:
LiveScaleLabel.h 与 LiveScaleLabel.m
// // LiveScaleLabel.h // ShowLabel // // Created by XianMingYou on 15/1/26. // Copyright (c) 2015年 XianMingYou. All rights reserved. // #import <UIKit/UIKit.h>@interface LiveScaleLabel : UIView@property (nonatomic) CGFloat beginScaleValue; @property (nonatomic) CGFloat endScaleValue;@property (nonatomic, strong) UIColor *normalStateColor; @property (nonatomic, strong) UIColor *maxStateColor;@property (nonatomic, strong) NSString *text; @property (nonatomic, strong) UIFont *font;@property (nonatomic) CGFloat sensitiveValue; // 敏感的值 @property (nonatomic) CGFloat currentValue; // 当前值- (void)buildView; - (void)accessCurrentValue:(CGFloat)currentValue;@end
// // LiveScaleLabel.m // ShowLabel // // Created by XianMingYou on 15/1/26. // Copyright (c) 2015年 XianMingYou. All rights reserved. // #import "LiveScaleLabel.h"@interface LiveScaleLabel ()@property (nonatomic, strong) UILabel *label; @property (nonatomic, strong) UIView *snapView; @property (nonatomic, strong) UILabel *maxLabel;@end@implementation LiveScaleLabel- (instancetype)initWithFrame:(CGRect)frame {if (self = [super initWithFrame:frame]) {[self setUpLabelWithFrame:self.bounds];}return self; }- (void)setUpLabelWithFrame:(CGRect)frame {self.label = [[UILabel alloc] initWithFrame:frame];self.label.textAlignment = NSTextAlignmentCenter;self.maxLabel = [[UILabel alloc] initWithFrame:frame];self.maxLabel.textAlignment = NSTextAlignmentCenter; }- (void)buildView {UIColor *normalStateColor = (self.normalStateColor == nil ? [UIColor blackColor] : self.normalStateColor);UIColor *maxStateColor = (self.maxStateColor == nil ? [UIColor redColor] : self.maxStateColor);UIFont *font = (self.font == nil ? [UIFont systemFontOfSize:16.f] : self.font);NSString *text = (self.text == nil ? @"" : self.text);// 设置基本样式self.label.text = text;self.label.textColor = normalStateColor;self.label.font = font;self.maxLabel.text = text;self.maxLabel.textColor = maxStateColor;self.maxLabel.font = font;// 截图 [self addSubview:self.label];[self addSubview:self.maxLabel];// 设定起始状态值 [self accessCurrentValue:self.currentValue]; }- (void)accessCurrentValue:(CGFloat)currentValue {CGFloat beginScaleValue = (self.beginScaleValue <= 0 ? 1.f : self.beginScaleValue);CGFloat endScaleValue = (self.endScaleValue <= 0 ? 1.f : self.endScaleValue);CGFloat sensitiveValue = (self.sensitiveValue <= 0 ? 320 : self.sensitiveValue);CGFloat percent = currentValue / sensitiveValue;if (percent >= 1) {percent = 1;} else if (percent <= 0) {percent = 0;}self.transform = CGAffineTransformMake(beginScaleValue + percent * endScaleValue, 0, 0,beginScaleValue + percent * endScaleValue, 0, 0);self.maxLabel.alpha = percent;self.label.alpha = 1 - percent; }@end
// // ViewController.m // ShowLabel // // Created by XianMingYou on 15/1/26. // Copyright (c) 2015年 XianMingYou. All rights reserved. // #import "ViewController.h" #import "LiveScaleLabel.h"@interface ViewController ()<UIScrollViewDelegate>@property (nonatomic, strong) UIScrollView *scrollView; @property (nonatomic, strong) LiveScaleLabel *liveLabelLeft; @property (nonatomic, strong) LiveScaleLabel *liveLabelRight; @property (nonatomic, strong) UIView *lineView;@end@implementation ViewController- (void)viewDidLoad {[super viewDidLoad];self.view.backgroundColor = [UIColor blackColor];// 左侧viewself.liveLabelLeft = [[LiveScaleLabel alloc] initWithFrame:CGRectMake(0, 300, 160, 30)];self.liveLabelLeft.normalStateColor = [UIColor grayColor];self.liveLabelLeft.text = @"YouXianMing";self.liveLabelLeft.endScaleValue = 0.2;self.liveLabelLeft.sensitiveValue = 320;[self.liveLabelLeft buildView];[self.liveLabelLeft accessCurrentValue:320];[self.view addSubview:self.liveLabelLeft];// 右侧viewself.liveLabelRight = [[LiveScaleLabel alloc] initWithFrame:CGRectMake(160, 300, 160, 30)];self.liveLabelRight.text = @"NoZuoNoDie";self.liveLabelRight.normalStateColor = [UIColor grayColor];self.liveLabelRight.maxStateColor = [UIColor cyanColor];self.liveLabelRight.endScaleValue = 0.2;self.liveLabelRight.sensitiveValue = 320;[self.liveLabelRight buildView];[self.view addSubview:self.liveLabelRight];self.scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];self.scrollView.delegate = self;self.scrollView.pagingEnabled = YES;self.scrollView.showsHorizontalScrollIndicator = NO;self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * 2,self.scrollView.frame.size.height);[self.view addSubview:self.scrollView];// 线条viewself.lineView = [[UIView alloc] initWithFrame:CGRectMake(0, 300 + 30, 160, 1)];UIView *backView = [[UIView alloc] initWithFrame:CGRectMake(20, 0, 120, 1)];backView.backgroundColor = [UIColor yellowColor];[self.lineView addSubview:backView];[self.view addSubview:self.lineView]; }- (void)scrollViewDidScroll:(UIScrollView *)scrollView {CGFloat x = scrollView.contentOffset.x;[self.liveLabelLeft accessCurrentValue:320 - x];[self.liveLabelRight accessCurrentValue:x];CGRect rect = self.lineView.frame;rect.origin.x = x / 2.f;self.lineView.frame = rect; }@end
转载于:https://www.cnblogs.com/YouXianMing/p/4248860.html
山寨凤凰新闻菜单效果相关推荐
- 高仿凤凰新闻的加载效果
高仿凤凰新闻的加载效果 介绍: 模仿凤凰新闻的加载.两个圆球旋转缩放.使用Animator属性动画. 本例子主要来自:http://www.itlanbao.com/code/20151208/100 ...
- 【推荐实践】信息流推荐在凤凰新闻的业务实践
分享嘉宾:马迪 凤凰网 技术总监 文章整理:吴雪松 出品平台:DataFun 导读:作为资讯阅读的用户产品,凤凰新闻一直在探索将AI赋能到内容生产和消费的全链路上.不断尝试调和AI算法与人的智慧相互约 ...
- 安卓逆向--凤凰新闻app简单分析
声明 本文章中所有内容仅供学习交流,不可用于任何商业用途和非法用途,否则后果自负,如有侵权,请联系作者立即删除!由于本人水平有限,如有理解或者描述不准确的地方,还望各位大佬指教!! 抓包分析 今天我们 ...
- 凤凰新闻自动评论推荐软件--把自己的评论推荐到最前面,然后通过头像、用户名或者评论内容进行展示
简介:自动搜索热门新闻进行自动评论,并且可以把自己的评论推荐到最前面,然后通过头像.用户名或者评论内容进行展示. 凤凰新闻自动评论推荐软件介绍: 凤凰新闻网是中国领先的综合门户网站,有着巨大的流量,凤 ...
- 信息流推荐在凤凰新闻的业务实践
分享嘉宾:马迪 凤凰网 技术总监 文章整理:吴雪松 内容来源:DataFunLive 出品平台:DataFun 注:欢迎转载,转载请在留言区留言. 导读:作为资讯阅读的用户产品,凤凰新闻一直在探索将A ...
- 竖直菜单 html,jQuery实现的网页竖向菜单效果代码
本文实例讲述了jQuery实现的网页竖向菜单效果代码.分享给大家供大家参考.具体如下: 这是一款基于jQuery实现竖向的网页菜单代码,可折叠展开的二级网页菜单,修改一下可用在后台管理中,显示在左侧的 ...
- 动态二级下拉菜单html,js实现简洁大方的二级下拉菜单效果代码
本文实例讲述了js实现简洁大方的二级下拉菜单效果代码.分享给大家供大家参考.具体如下: 这是一款简洁大方的二级下拉菜单,菜单的颜色自己根据需要重新定义吧,这里仅给大家提供一种制作二级菜单的思路,整体效 ...
- 手风琴html例子,jquery实现简单手风琴菜单效果实例
本文实例讲述了jquery实现简单手风琴菜单效果的方法.分享给大家供大家参考.具体实现方法如下: dd').hide(); $('.accordion > dt > a').click(f ...
- html下拉列表插件,js+CSS实现模拟华丽的select控件下拉菜单效果
本文实例讲述了js+CSS实现模拟select控件的下拉菜单效果.分享给大家供大家参考.具体如下: 这是一个JS+CSS技术实现的Select控件效果,模拟出来的,比默认的Select更漂亮,有了这个 ...
最新文章
- 同济大学计算机云南2019,同济大学录取分数线2019(在各省市录取数据)
- python爬虫入门(六) Scrapy框架之原理介绍
- 基于R语言的梯度推进算法介绍
- 织梦需要php什么版本,DedeCmsV5.1FreeSP1正式版发布
- PooledByteBuf源码分析
- 处理上百万条的数据库如何提高处理查询速度
- Java/Android引用类型及其使用分析
- 超越竞争(2) 价值创新
- Idea报错,但是项目可以正常启动运行
- oracle 10g管理地址,oracle10g管理共享服务器
- Uniapp实现实时音视频的基础美颜滤镜功能
- Modbus协议解析
- fedora linux搜狗输入法,GitHub - Hello-Linux/fedora-Sougou-Pinyin: fedora 搜狗拼音,安装超简单,各种精美皮肤!...
- linux查询系统版本信息命令,命令查询windowsLinux系统版本信息
- ES已经安装了ik分词器,仍然报错analyzer [ik_max_word] not found for field
- POJ 1370 Gossiping 笔记
- 由ip地址和子网掩码求网络号、主机号、广播地址(超详细)
- Aspose.Words for .NET使用教程(十二):在Word文档中使用图表轴
- 本地项目关联远程 git 仓库
- 22.JS+jQuery