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

CGRect gradientRect=CGRectMake(- imageView3.bounds.size.width*, * imageView3.bounds.size.width, imageView3.bounds.size.height); CAGradientLayer *gradientLayer = [CAGradientLayer layer]; gradientLayer.frame =gradientRect; gradientLayer.colors = @[(id)…
前言 UIView 不像 UIButton 加了点击事件就会有点击效果,体验要差不少,这里分别通过自定义和扩展来实现类似 UIButton 的效果. 声明 欢迎转载,但请保留文章原始出处:) 博客园:http://www.cnblogs.com 农民伯伯: http://over140.cnblogs.com 正文 一.为 UIView 添加点击事件 extension UIView { func addOnClickListener(target: AnyObject, action: Sel…
对于不能addTarget的UI对象,添加手势为他们带来了“福音”,以为UIView添加手势为例,揭开手势的面目. 1,创建一个view先, UIView * jrView=[[UIViewalloc] initWithFrame:CGRectMake(, , , )]; jrView.center=self.view.center; jrView.backgroundColor=[UIColorgreenColor]; [self.viewaddSubview:jrView]; 2,添加手势…
创建UIImage的方法有两种: UIImage *image = [UIImageimageNamed:@"image.jpg"];//这种不释放内存,要缓存 NSString *path = [[NSBundlemainBundle]pathForResource:@"image"ofType:@"jpg"]; UIImage *image1 = [UIImageimageWithContentsOfFile:path];//这种会释放内存…
给UIView添加背景图片 //默认情况下只能设置UIView的背景颜色,不能给UIView设置背景图片,但通过绘图知识可以做到 - (void)drawRect:(CGRect)rect { [super drawRect:rect]; [[UIImage imageNamed:@"mainCellBackground"]drawInRect:rect]; } 如果在某个时间点,view的frame变化了,需要调用 [view setNeedsDisplay]; 方法在下次屏幕刷新时…
怎样给UIview添加背景图片呢很简单,就是先给view添加一个subview,然后设为背景图片: 效果图如下: 很简单直接上代码: //设置内容 self.myTopView.backgroundColor=[UIColor grayColor]; self.nameLabel.textColor=[UIColor blackColor]; self.addLabel.textColor=[UIColor blackColor]; self.nameLabel.font=[UIFont bol…
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(actionTap)]; [aView addGestureRecognizer:tap]; [tap release]; 以上是很简单的给一个UIView 添加 单击手势的方法. 下面我们来改进他支持代码快 先建立一个类别 @interface UIView (XY) -(void) addTapG…
圆角 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…
前言:好久没写博客,今天来一波.我在实际项目开发中,会遇到这样功能需求:我已经搭好了iOS的UI界面,但是很多界面的子View用了UIView,然后这些UIView中用了UILabel和UIImageView,然后接着需求要这些View能够有点击事件,比如一点击就跳转到某个控制器.一开始懵逼了,难道我还要把他们全部改成UIButton,但是UIButton不好添加子View,难道我还要全部自定义一下UIButton,就算自定义好了,在项目已经打好的界面还是要一个个替换,多麻烦.所以就想到通过UI…
添加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…