UIView 添加闪烁的渐变光

CGRect gradientRect=CGRectMake(- imageView3.bounds.size.width*1.5, 0, 4 * imageView3.bounds.size.width, imageView3.bounds.size.height);
    CAGradientLayer *gradientLayer = [CAGradientLayer layer];
    gradientLayer.frame =gradientRect;
    gradientLayer.colors = @[(id)hexColor(bb975e).CGColor,(id)[UIColor whiteColor].CGColor,(id)hexColor(bb975e).CGColor];
    gradientLayer.locations = @[@(0.25),@(0.5),@(0.75)];
    gradientLayer.startPoint = CGPointMake(0, 0.5);
    gradientLayer.endPoint = CGPointMake(1, 0.5);
    gradientLayer.position = CGPointMake(imageView3.bounds.size.width*0.5, imageView3.bounds.size.height/2.0);
    [imageView3.layer addSublayer:gradientLayer];

    CALayer *maskLayer = [CALayer layer];
    maskLayer.frame =CGRectOffset(imageView3.bounds, imageView3.bounds.size.width*1.5, 0);
    maskLayer.contents = (__bridge id)([UIImage imageNamed:@"launchImage3"].CGImage);
    gradientLayer.mask = maskLayer;

    CABasicAnimation* fadeAnim = [CABasicAnimation animationWithKeyPath:@"locations"];
    fadeAnim.fromValue = @[@(0.0),@(0.0),@(0.25)];
    fadeAnim.toValue = @[@(0.75),@(1.0),@(1.0)];
    fadeAnim.duration=2;
    fadeAnim.repeatCount = CGFLOAT_MAX;
    [gradientLayer addAnimation:fadeAnim forKey:nil];
时间: 2024-10-02 23:17:44

UIView 添加闪烁的渐变光的相关文章

IOS UIView圆角,阴影,边框,渐增光泽

圆角 sampleView.layer.cornerRadius = 2.5; // 圓角的弧度sampleView.layer.masksToBounds = YES; 阴影 sampleView.layer.shadowColor = [[UIColor blackColor] CGColor];sampleView.layer.shadowOffset = CGSizeMake(3.0f, 3.0f); // [水平偏移, 垂直偏移]sampleView.layer.shadowOpaci

Swift中给UIView添加Badge

extension UIView{ //任意UIView添加badge func showBadgeValue(#strBadgeValue: String) -> Void{ let tabBar = UITabBar(frame: CGRectMake(0, 0, 320, 50)) let item = UITabBarItem(title: "", image: nil, tag: 0) item.badgeValue = strBadgeValue let array

给UIView添加手势

对于不能addTarget的UI对象,添加手势为他们带来了“福音”,以为UIView添加手势为例,揭开手势的面目. 1,创建一个view先, UIView * jrView=[[UIViewalloc] initWithFrame:CGRectMake(0, 0, 160, 160)]; jrView.center=self.view.center; jrView.backgroundColor=[UIColorgreenColor]; [self.viewaddSubview:jrView];

【Swift 2.1】为 UIView 添加点击事件和点击效果

前言 UIView 不像 UIButton 加了点击事件就会有点击效果,体验要差不少,这里分别通过自定义和扩展来实现类似 UIButton 的效果. 声明 欢迎转载,但请保留文章原始出处:) 博客园:http://www.cnblogs.com 农民伯伯: http://over140.cnblogs.com 正文 一.为 UIView 添加点击事件 extension UIView { func addOnClickListener(target: AnyObject, action: Sel

网站设计之Flash简单动画入门介绍(一)字体闪烁及渐显

在制作网站过程中,增加些动画效果是非常美妙的一件事.由于最近在当Flash和PS课程的助教,也辅导学生完成PS.Flash.HTML等操作,所以这篇文章主要是对Flash动画的入门介绍,希望对你有所帮助,因为是非常基础甚至没有涉及到代码的文章,如果文章中存在错误或不足之处,还请海涵~ 一. 软件介绍 该软件主要使用Macromedia Flash Professional 8实习,而最常用的软件是Adobe Flash CS5,原理和操作基本类似.        首先创建一个Flash文档,Ad

#iOS开发常用方法集锦#如何为UIView添加居中背景

?本文永久地址为?http://www.cnblogs.com/ChenYilong/p/4103050.html,转载请注明出处. Evernote印象笔记:https://app.yinxiang.com/shard/s22/sh/2fe4cb0f-26cb-47ce-8569-bb45451cb7b8/6118d5a054003de9 //如何为UIView添加居中背景 #define kBackgroundImageCenterForView(ViewName,imageName)\ U

IOS - UIView添加点击事件

UIView通过手势(Gesture-UITapGestureRecognizer)添加点击事件, 类似于UIButton的效果. 示例: UIImageView *iKnowIcon = [CYResource loadImageView:@"free-question-once-more-i-know.png"]; iKnowIcon.top = questionIcon.top + scaleWidthWith320(200); iKnowIcon.centerX = self.

iOS 给UIView添加xib

一段时间没敲代码,以前一些简单的都不会做了,翻找又麻烦,所以还是记录下. 1.打开项目,新建一个继承于UIView的类AAA: 2.新建一个空白的XIB,同样取名AAA 3.将xib与UIView关联,点击File's Owner ,类选择AAA视图.   ---> 4.在xib上拉个View,设置背景位红色,在控制器上调用这个UIView,测试效果,运行后正常显示. //调用xib视图, AAA *av =[[[NSBundle mainBundle]loadNibNamed:@"AAA

swift为UIView添加extension扩展frame

添加swift file:UIView+Extension import UIKit extension UIView { // x var x : CGFloat { get { return frame.origin.x } set(newVal) { var tmpFrame : CGRect = frame tmpFrame.origin.x = newVal frame = tmpFrame } } // y var y : CGFloat { get { return frame.o