小编Joh*_*ohn的帖子

CAGradientLayer中的CABasicAnimation不起作用 - 我做错了什么?

我有一个自定义的UITableView单元格,它有一个按钮和一个标签.当有人点击按钮时,我会触发一个方法,然后为该行着色.一切正常.

我想要真正做的是

  1. 用户点击按钮,该行以渐变着色(现在可以使用)
  2. 渐变消失了

我的代码如下(BackView是我的自定义单元格中的视图)

CAGradientLayer *layer = [CAGradientLayer layer];
layer.frame = BackView.bounds;

UIColor *cOne     = [UIColor paleYellowColor];
UIColor *cTwo     = [UIColor whiteColor];

NSArray *colors =  [NSArray arrayWithObjects:(id)cOne.CGColor,
                    cTwo.CGColor, nil];

layer.colors = colors;

NSNumber *stopOne     = [NSNumber numberWithFloat:0.00];
NSNumber *stopTwo     = [NSNumber numberWithFloat:0.8];

NSArray *locations = [NSArray arrayWithObjects:stopOne, stopTwo, nil];
layer.locations = locations;

CABasicAnimation *animateLayer = [CABasicAnimation animationWithKeyPath:@"colors"];
animateLayer.fromValue = [UIColor paleYellowColor];
animateLayer.toValue = [UIColor whiteColor];
animateLayer.duration   = 3.0;
animateLayer.removedOnCompletion = YES;
animateLayer.fillMode = kCAFillModeBoth;
animateLayer.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
[layer …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch core-animation

5
推荐指数
1
解决办法
1864
查看次数

一个很好的XCode示例项目,包括SQlite,tableview,starring和reordering

我是Objective-C/XCode的完全新手,到目前为止它有点令人生畏.我希望通过构建包含一些概念的东西来弄脏我的手.

我想要做的就是有一个表,该表由SQLite数据库中的行填充.该表应具有重新排序功能,我想拥有一个主演设施,然后删除(我认为是标准的)

当然,我可以通过查看一些示例项目来解决这个问题,但我想知道是否有一个好的示例项目具有这些功能,我可以将其视为一个起点.如果没有,也谢天谢地接受任何其他推荐的样本项目.

iphone xcode objective-c

1
推荐指数
1
解决办法
9726
查看次数

标签 统计

iphone ×2

cocoa-touch ×1

core-animation ×1

objective-c ×1

xcode ×1