小编Mar*_*ios的帖子

用颜色填充图像的一部分

我正在做一个iPhone绘画应用程序.我想使用touchevent绘制图像的特定部分以找到像素数据,然后使用该像素数据绘制图像的剩余部分.使用touchevent,我得到了该部分的像素值:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

    UITouch *touch = [touches anyObject];
    startPoint = [[touches anyObject] locationInView:imageView];

    NSLog(@"the value of the index is %i",index);

    NSString* imageName=[NSString stringWithFormat:@"roof%i", index];

    tempColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:imageName]];
    lastPoint = [touch locationInView:self.view];
    lastPoint.y -= 20;
    NSString *tx = [[NSString alloc]initWithFormat:@"%.0f", lastPoint.x];
    NSString *ty = [[NSString alloc]initWithFormat:@"%.0f", lastPoint.y];

    NSLog(@"the vale of the string is %@  and %@",tx,ty);

    int ix=[tx intValue];
    int iy=[ty intValue];
    int z=1;

    NSLog(@"the vale of the string is %i  and %i and …
Run Code Online (Sandbox Code Playgroud)

iphone ios

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

使用所选区域的矩形框裁剪图像?

我正在寻找一个很好的教程或示例代码,它将展示如何从iphone相机中裁剪图像

一些东西

在此输入图像描述

但你会用手指控制角落

任何提示都会非常明显,因为我试图以多种方式但没有得到结果.

cocoa-touch crop objective-c ios

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

使用componentsSeparatedByString时,只能从"UIDeviceRGBColorSpace 1 1 1 1"获取值,sigabrt会发生吗?

我的字符串值是这个//字符串应该是这样的 "UIDeviceRGBColorSpace 0.5 0 0.25 1"

我正在解析字符串以单独获取颜色值

 -(UIColor*)colorFromNSString:(NSString *)string {


        NSMutableArray *values = [string componentsSeparatedByString:@""];
        CGFloat red = [[values objectAtIndex:1] floatValue];
        CGFloat green = [[values objectAtIndex:2] floatValue];
       CGFloat blue = [[values objectAtIndex:3] floatValue];
      CGFloat alpha = [[values objectAtIndex:4] floatValue];
      UIColor *color = [UIColor colorWithRed:red green:green blue:blue alpha:alpha];
   //     NSLog(@"the color in string is %@",red);
       return color;
}
Run Code Online (Sandbox Code Playgroud)

我正在查找此行中sigabrt的错误消息

NSMutableArray *values = [string componentsSeparatedByString:@""];
Run Code Online (Sandbox Code Playgroud)

崩溃日志是

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM componentsSeparatedByString:]: unrecognized selector sent to instance 0x4b4a3e0' …
Run Code Online (Sandbox Code Playgroud)

iphone xcode ios

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

标签 统计

ios ×3

iphone ×2

cocoa-touch ×1

crop ×1

objective-c ×1

xcode ×1