Tag: calayer

立即更新CALayer子层

我有UIView它有以下结构: UIView |- layer (CALayer) |- depthLayer (CALayer) |- bodyLayer (CALayer) 对于我设置needsDisplayOnBoundsChange = true的图层 。 当我改变UIView的大小, 层立即重绘。 但他们的子层更新有一些延迟(在下一个绘制迭代)。 如何同步sublayers depthLayer和bodyLayer的图层绘制? UIView的: override func drawRect(rect: CGRect) { bodyLayer.frame = rect depthLayer.frame = CGRectOffset(rect, 0, 5) }

iOS – CAShapeLayer消除锯齿?

我有两个相邻的菱形,我希望他们的边缘无缝地融合在一起。 此刻,由于抗锯齿,即使边缘尽可能靠近,背景也会stream血。 我不想重叠形状。 有没有人有任何提示? 谢谢

我如何添加跨越两个视图的渐变?

我知道该怎么做(1)但我该怎么做(2)? UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 50)]; CAGradientLayer *gradient = [CAGradientLayer layer]; gradient.frame = view.bounds; gradient.colors = @[(id)[UIColor blueColor].CGColor, (id)[UIColor redColor].CGColor]; [view.layer insertSublayer:gradient atIndex:0];

我如何确定CALayer是否被其他CALayer完全覆盖?

我有一系列随机放置在屏幕上的图层。 随着每个图层的添加,它被定位在所有其他图层之上。 最终,一个图层被其他图层完全覆盖。 在这一点上,我想从内存中删除图层。 有什么方法可以知道一个图层何时被其他图层覆盖(100%或一些分数)? 每个图层都有一个旋转变换,所以我不能准确地在所有图层的框架之间进行比较。

与CALayers CAAnimation偶尔创build闪烁的animation(包括video)

我的应用程序需要一个静止的照片,并animation口区域模仿说话。 但是,大约1/4的时间内,一些隐藏的calayers将在整个animation中不断闪烁。 这是应用程序正常工作时的样子。 这是应用程序在发生故障时的样子。 编辑:一个更好的video 我假设这个问题是path相关的。 在应用程序中,用户在嘴部区域周围创build一个path(在video中简要显示),这将是animation区域。 有时path会导致一个平滑的animation,有时候会导致上面的小故障。 此外,如果我按下“back”并尝试用animation重新加载控制器,则毛刺会持续存在,而如果在重新加载之前更改path,则偶尔会消失。 如果不是path相关,我已经消除的一些罪魁祸首是: 图像types/来源 – 有时它将适用于图像a,但不适用于图像b,其他时间适用于图像b,但不适用于a。 我已经尝试了照片库的图像以及从互联网上保存的图像。 iPhone vs模拟器 – 两个设备上都出现问题 animation数量 – 有时会在第一次尝试时发生; 其他时间会发生在5日或6日尝试。 下面是从视图的代码animation。 我首先创build一个全黑的图层,然后是一个图层减去嘴部区域,最后是一个刚才的嘴部区域。 然后,我改变了嘴巴的位置,使位移变成黑色,看起来像张开的嘴。 编辑:另外,如果我通过从面层去除蒙版去除嘴孔,animation运行平稳。 – (id)initWithFrame:(CGRect)frame leftPt:(CGPoint)point0 rightPt:(CGPoint)point2 vertex1:(CGPoint)vertex1 vertex2:(CGPoint)vertex2 andPicture:(UIImage *)pic{ self = [super initWithFrame:frame]; if (self) { p0 = point0; p2 = point2; v1 = vertex1; v2 = vertex2; picture = […]

捕获UIView的图像(renderInContext工作不正常)

我正在尝试使用renderInContex捕获一个UIView的图像,但它不能完全捕获所有的子视图。 (例如,它不捕获UITextView的单词,并且根本不捕获UIButton 。) 我可以用什么来代替? 编辑:问题其实不是renderInContext ,而是我的实现。 看到我的新问题: https : //stackoverflow.com/q/8865207/542687

animationCALayer背景颜色和更新模型值

我想为我的UIView(在tintColorDidChange )中的一个子图层的backgroundColor改变animation。 我需要从图层的当前背景颜色animation多次到新的色调颜色(每次不同的色调),所以需要更新backgroundColor的模型值(我不能在animation上使用removedOnCompletion = false )。 使用CABasicAnimation我有颜色更改animation工作正常,如果我不更新模型值(但当然animation完成后颜色重置)。 当我尝试更新模型值时,颜色变化立即发生,animation丢失。 我试图禁用隐式animation并使用CATransation更新模型值,但animation仍然丢失。 我如何更新backgroundColor模型的值,并保持我的淡出animation工作? override func tintColorDidChange() { super.tintColorDidChange() let colourAnim = CABasicAnimation(keyPath: "backgroundColor") colourAnim.toValue = self.tintColor.CGColor colourAnim.duration = 1.0 self.spinnerLayer?.addAnimation(colourAnim, forKey: "colourAnimation") CATransaction.begin() CATransaction.setDisableActions(true) self.spinnerLayer?.backgroundColor = self.tintColor.CGColor CATransaction.commit() }

我如何可以自定义borderWidth的所有UITextField外观?

我正在尝试为borderWith定制所有UITextField外观。 尝试这样的事情。 只有前两行有所作为。 其余的线路不工作? [[UITextField appearance] setBackgroundColor:[UIColor greenColor]]; [[UITextField appearance] setTextColor:[UIColor blackColor]]; [UITextField appearance].layer.cornerRadius = 6.0f; [UITextField appearance].layer.borderColor = [UIColor redColor].CGColor; [UITextField appearance].layer.borderWidth = 3.f;

在iOS中设置CALayer'borderWidth'和'cornerRadius',不能完全覆盖背景

– (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. self.yuanjiao.backgroundColor = [UIColor blackColor]; self.yuanjiao.layer.cornerRadius = self.yuanjiao.frame.size.width/2; self.yuanjiao.layer.masksToBounds = YES; self.yuanjiao.layer.borderWidth = 5; self.yuanjiao.layer.borderColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:1].CGColor; // self.yuanjiao.layer.shadowOffset = CGSizeMake(0, 0); // self.yuanjiao.layer.shadowRadius = 0.0; // self.yuanjiao.layer.shadowColor = [UIColor whiteColor].CGColor; // self.yuanjiao.layer.shadowOpacity = […]

在滚动后删除CALayer到UITableViewCell

我正在尝试将CALayer添加到我的UITableViewCell的底部以获得一些“影子”效果。 问题是当表格向上滚动并移出图层时,所以当你向下滚动时,它不可见。 如果从屏幕向下滚动单元格,然后备份,他们显得很好。 我有一个GIF在这里显示发生了什么事情。 这是我如何做到这一点: – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *cellIdentifier = @"CellIdentifier"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; if (!cell) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier]; } cell.textLabel.text = [NSString stringWithFormat:@"Row %d", (int)indexPath.row]; CALayer *bottomBorder = [CALayer layer]; bottomBorder.frame = CGRectMake(0.0f, cell.frame.size.height, cell.frame.size.width, 1.0f); bottomBorder.backgroundColor = [UIColor colorWithWhite:0.9f alpha:1.0f].CGColor; [cell.layer […]