小编ago*_*rov的帖子

如何从RGBA创建UIColor?

我想用NSAttributedString在我的项目,但是当我试图设置颜色,这是不是从标准组(redColor,blackColor,greenColor等)UILabel显示在白色这些信件.这是我的代码行.

[attributedString addAttribute:NSForegroundColorAttributeName
                         value:[UIColor colorWithRed:66
                                               green:79
                                                blue:91
                                               alpha:1]
                         range:NSMakeRange(0, attributedString.length)];
Run Code Online (Sandbox Code Playgroud)

我尝试使用CIColorCore Image框架制作颜色,但它显示了相同的结果.我应该如何更改代码以正确的方式执行它?

伙计们,谢谢!

rgb objective-c nsattributedstring uicolor ios

44
推荐指数
3
解决办法
6万
查看次数

正弦CAShapeLayer作为CALayer的面具

我正在尝试实现下一个奇怪的事情:我有几个点,我想用正弦波连接它们

下一个方法返回用于制作绘图的点阵列:

- (NSArray *)plotPointsBetweenPoint:(CGPoint)pointA andPoint:(CGPoint)pointB {
  double H = fabs(pointB.y - pointA.y);
  double L = fabs(pointB.x - pointA.x);

  NSInteger granularity = 40;
  NSMutableArray *array = [NSMutableArray arrayWithCapacity:granularity + 1];
  for (int i = 0; i <= granularity; ++i) {
    CGFloat x = M_PI*(float)i/(granularity);
    CGFloat y = -cosf(x);
    CGFloat multiplier = pointA.y > pointB.y ? 1 : -1;
    CGPoint newPoint = CGPointMake(pointA.x + L*(float)i/granularity, pointA.y - multiplier*H*(1.0 + y)/2.0);
    [array addObject:[NSValue valueWithCGPoint:newPoint]];
  }
  return array;
}
Run Code Online (Sandbox Code Playgroud)

之后我创建了特殊的UIBezierPath:

- …
Run Code Online (Sandbox Code Playgroud)

core-graphics cashapelayer ios uibezierpath

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