当前位置: 首页 > news >正文

济南制作网站公司app下载量推广

济南制作网站公司,app下载量推广,40个创意包装盒设计,南海专业网站建设公司效果图 该跑马灯完全通过CATextLayer 实现,轻量级,并且通过 系统的位移动画实现滚动效果,避免了使用displaylink造成的性能瓶颈,使用系统动画,系统自动做了很多性能优化,实现更好的性能,并使用…

效果图
请添加图片描述

该跑马灯完全通过CATextLayer 实现,轻量级,并且通过
系统的位移动画实现滚动效果,避免了使用displaylink造成的性能瓶颈,使用系统动画,系统自动做了很多性能优化,实现更好的性能,并使用遮罩实现展示范围的限定
,实现跑马灯效果

//
//  LBMarqueeLayer.m
//  TEXT
//
//  Created by mac on 2024/4/28.
//  Copyright © 2024 刘博. All rights reserved.
//#import "LBMarqueeLayer.h"@implementation LBMarqueeLayerConfig- (instancetype)init
{self = [super init];if (self) {self.velocity = 20;self.fontSize = 14;self.textColor = [UIColor darkGrayColor];self.pauseDuration = 3;self.blankString = @"  ";}return self;
}@end@interface LBMarqueeLayer () <CAAnimationDelegate>@property (nonatomic, strong) CATextLayer *textLayer;@property (nonatomic, strong) CALayer *maskLayer;@property (nonatomic, strong) LBMarqueeLayerConfig *config;@property (nonatomic, strong) CABasicAnimation *animation;@end@implementation LBMarqueeLayer- (instancetype)initwithFrame:(CGRect)frameconfig:(LBMarqueeLayerConfig *)config
{if ([super init]) {self.frame = frame;self.config = config;[self handleText];[self addSublayer:self.textLayer];}return self;
}- (void)handleText
{CGFloat width = [self.config.text sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:self.config.fontSize]}].width;if (width > CGRectGetWidth(self.bounds)) {NSString *content = [NSString stringWithFormat:@"%@%@%@", self.config.text, self.config.blankString, self.config.text];NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:content attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:self.config.fontSize]}];self.textLayer.string = attributedString;CGFloat width = [content sizeWithAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:self.config.fontSize]}].width;self.textLayer.frame = CGRectMake(0, 0, width, CGRectGetHeight(self.bounds));CGFloat toValue = [[NSString stringWithFormat:@"%@%@", self.config.text, self.config.blankString] sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:self.config.fontSize]}].width;self.animation.fromValue = @(0);self.animation.toValue = @(-toValue);self.animation.duration = toValue/self.config.velocity;[self.textLayer addAnimation:self.animation forKey:@"animation"];self.masksToBounds = YES;} else {self.textLayer.string = self.config.text;}}#pragma mark - animationDelegate- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag{if (flag) {dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(self.config.pauseDuration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{[self.textLayer addAnimation:self.animation forKey:@"animation"];});}}#pragma mark - lazy load- (CATextLayer *)textLayer{if (!_textLayer) {_textLayer = [[CATextLayer alloc] init];_textLayer.frame = CGRectMake(0, 0, CGRectGetWidth(self.frame), CGRectGetHeight(self.frame));_textLayer.alignmentMode = kCAAlignmentLeft;_textLayer.fontSize = 14;_textLayer.foregroundColor = self.config.textColor.CGColor;}return _textLayer;}- (CALayer *)maskLayer{if (!_maskLayer) {_maskLayer = [[CALayer alloc] init];_maskLayer.frame = self.bounds;}return _maskLayer;}- (CABasicAnimation *)animation{if (!_animation) {_animation = [CABasicAnimation animationWithKeyPath:@"transform.translation.x"];if (!self.config.hasPause) {_animation.repeatCount = NSIntegerMax;}_animation.delegate = self;}return _animation;}@end

调用


- (LBMarqueeLayer *)textLayer
{if (!_textLayer) {LBMarqueeLayerConfig *config = [[LBMarqueeLayerConfig alloc] init];config.hasPause = YES;config.pauseDuration = 3;config.blankString = @"      ";config.text = @"这是一首非常好听的歌曲哈哈哈哈";_textLayer = [[LBMarqueeLayer alloc] initwithFrame:CGRectMake(100, 100, 200, 50) config:config];_textLayer.backgroundColor = [UIColor cyanColor].CGColor;}return _textLayer;
}
http://www.hkea.cn/news/553833/

相关文章:

  • 工厂外贸网站建设台州网络推广
  • 酒店网站建设方案策划百度seo怎么做网站内容优化
  • 网站更改公司需要重新备案吗搜索网页内容
  • 现在做网站还用dw做模板了吗成人电脑速成培训班
  • 做app要不要建网站刚开的店铺怎么做推广
  • 做生存分析的网站有哪些专业的网站优化公司
  • 网站双倍浮动百度联盟app
  • 北京网站设计确保代码符合w3c广州网络营销的推广
  • 做网站实名认证有什么用百度移动端模拟点击排名
  • 知更鸟wordpress 怎样沈阳百度seo关键词优化排名
  • 携程网站模板互联网营销策略有哪些
  • 做网站内链什么意思上海排名优化seobwyseo
  • 四川做直销会员网站百度网盘帐号登录入口
  • 做百度竞价对网站有无要求网站推广排名服务
  • 建设工程合同包括成都网站改版优化
  • 深圳不加班的互联网公司整站seo优化
  • 中国做的很好的食品网站肇庆疫情最新消息
  • 做时时彩网站微信seo关键词有话要多少钱
  • 陇南市建设局网站商务软文写作
  • 做学术研究的网站营销方案怎么写?
  • 专业网站设计公司有哪些秒收录关键词代发
  • 织梦网站模板源码下载真实有效的优化排名
  • 网站建设过程中什么最重要磁力链bt磁力天堂
  • html5企业网站案例鹤壁搜索引擎优化
  • 网站建设平台简介链接交换平台
  • 照片展示网站模板宁波seo咨询
  • 奉贤建设机械网站制作长沙网址seo
  • 上海企业网站模板建站常用的网络推广方法
  • 大连零基础网站建设教学培训济南seo优化公司
  • html 做网站案例简单网站推广建设