Tag: uiimageview

“不能分配给属性:”任何“是不可变的”错误

tiledViewsStack包含UIImageViews。 我试图给数组中的每个UIImageView一个新的中心坐标。 不知道为什么我得到这个错误的for循环的最后一行… var tiledViewsStack = [AnyObject]() var randLocInt = Int() var randLoc = CGPoint() for var any in tiledViewsStack { randLocInt = Int((arc4random()*10) % 9) // 0, — 8 randLoc = allCenters[randLocInt].CGPointValue() any.center = randLoc }

UIImageView animationRepeatCount奇怪的行为

所以我有这样的代码,animation一组图像无限次的数量就好了,但只要我试图限制它的animation次数简直不起作用。 甚至没有图像显示。 代码工作: animatedMap.animationImages = [NSArray arrayWithObjects: [UIImage imageNamed:@"0.gif"], [UIImage imageNamed:@"1.gif"], [UIImage imageNamed:@"2.gif"], [UIImage imageNamed:@"3.gif"], //etc…]; animatedMap.animationDuration = 20.0f; animatedMap.animationRepeatCount = 0; [animatedMap startAnimating]; 不起作用的代码: animatedMap.animationImages = [NSArray arrayWithObjects: [UIImage imageNamed:@"0.gif"], [UIImage imageNamed:@"1.gif"], [UIImage imageNamed:@"2.gif"], [UIImage imageNamed:@"3.gif"], //etc…]; animatedMap.animationDuration = 20.0f; animatedMap.animationRepeatCount = 1; [animatedMap startAnimating]; 这似乎真的很奇怪的行为?

将GestureRecogniser附加到多个图像浏览

今天遇到的一些奇怪的事情,同时将同一个手势识别器连接到多个图像视图。 它只附加到最后一个,换句话说,它可以附加到只有一个视图! 我不得不创build多个手势识别器来满足我的要求。 以下是我所做的。 我正确吗? 这是将识别器附加到多个图像视图的唯一方法吗? 请注意,我不想使用UITableView或UIVIew,并把所有的图像,并附加手势识别器只有UITableView或UIVIew。 我有所有图像分散,我必须检测哪个图像被拖动。 谢谢。 [imgView1 setUserInteractionEnabled:YES]; [imgView1 setMultipleTouchEnabled:YES]; [imgView2 setUserInteractionEnabled:YES]; [imgView2 setMultipleTouchEnabled:YES]; [imgView3 setUserInteractionEnabled:YES]; [imgView3 setMultipleTouchEnabled:YES]; [imgView4 setUserInteractionEnabled:YES]; [imgView4 setMultipleTouchEnabled:YES]; [imgView5 setUserInteractionEnabled:YES]; [imgView5 setMultipleTouchEnabled:YES]; [imgView6 setUserInteractionEnabled:YES]; [imgView6 setMultipleTouchEnabled:YES]; //Attach gesture recognizer to each imagviews gestureRecognizer1 = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(gestureHandler:)]; gestureRecognizer1.delegate = self; gestureRecognizer2 = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(gestureHandler:)]; gestureRecognizer2.delegate […]

为UIImage制作圆angular

在我的iPhone应用程序中,我必须显示一个UIImage,其四个angular都弯曲,以便在屏幕上看起来很好。 但是,我的图像是一个矩形的图像,不能在图像级别更改,因为它来自第三方。 用UIImageView我可以设置框架。 使用代码,我怎样才能修改我的UIImage有圆angular? 任何线索?

如何将图像拉伸成自定义形状(swift3)

下面的代码列表裁剪图像。 我希望图像被转换/拉伸,而不是在形状中裁剪。 所有的图像内容仍然在转换后的图像中。 它只会看起来不同。 extension UIImageView { func addMask(_ bezierPath: UIBezierPath) { let pathMask = CAShapeLayer() pathMask.path = bezierPath.cgPath layer.mask = pathMask } } let myPicture = UIImage(data: try! Data(contentsOf: URL(string:"https://scontent-iad3-1.xx.fbcdn.net/v/t31.0-8/14196150_10207770295835716_3510332720585393213_o.jpg?oh=fdb525410602f40f4735991b713e9c50&oe=596688E5")!))! let iv = UIImageView(image: myPicture) let bezierPath = UIBezierPath() bezierPath.move(to: iv.center) bezierPath.addLine(to: CGPoint(x: iv.frame.maxX, y: 0)) bezierPath.addLine(to: CGPoint(x: iv.frame.maxX, y: iv.frame.maxY)) bezierPath.addLine(to: CGPoint(x: 0, […]

外部延伸和内部的可调整的UIImage保持不变

我正在尝试在我的应用中为垂直条创build一个“抓地力”,以向用户显示他们可以在视图上滑动。 我想只使用一个小的版本的图像,它具有抓地力和1px的上下,这是酒吧的其余部分的背景。 所以: ssss ssss gggg becomes ssss ssss gggg ssss ssss 方法resizableImageWithCapInsets:允许你告诉iOS不调整外部边缘,但有没有办法告诉它不要调整内部和外部拉伸? 我已经试过指定一个超大的帽子插入, UIEdgeInsetsMake(29.0f, 0.0f, 29.0f, 0.0f)并导致夹在图像的框架的顶部,但是否则是我正在寻找正确的伸展行为对于。 我只需要把握部分在框架中心。 完整的代码对于那些有兴趣的人来说(这导致了整个长度的重复): gripBar = [[UIImageView alloc] initWithImage:[[UIImage imageNamed:@"grip"] resizableImageWithCapInsets:UIEdgeInsetsMake(1.0f, 0.0f, 1.0f, 0.0f)]]; gripBar.frame = CGRectMake(0, 0, gripWidth, fullHeight); [view gripBar]; 更新:基于所选答案的工作代码 @implementation GripBar – (id)init { self = [super init]; if (self) { UIImageView *bar = [[UIImageView […]

如何在UIImageView的左上angular和右下angular创buildUIButton

我希望在imageview的左上angular和右下angular创build删除button。 但它看起来不像我所需要的。 我希望这两个button应该放在红色边框的angular落 要创buildbutton我使用下面的代码 UIImageView * tappedView = (UIImageView *)[recognizer view]; [tappedView.layer setBorderColor: [[UIColor redColor] CGColor]]; [tappedView.layer setBorderWidth: 2.0]; tappedView.layer.cornerRadius = 10; tappedView.layer.masksToBounds = NO; UIButton *deleteBtn = [UIButton buttonWithType:UIButtonTypeCustom]; deleteBtn.frame = CGRectMake(0, 0, 20, 20); [deleteBtn setImage:[UIImage imageNamed:@"close.png"]forState:UIControlStateNormal]; deleteBtn.layer.shadowColor = [[UIColor blackColor] CGColor]; deleteBtn.layer.shadowOffset = CGSizeMake(0,4); deleteBtn.layer.shadowOpacity = 0.3; [tappedView addSubview:deleteBtn]; [deleteBtn addTarget:self action:@selector(deleteProperties:) […]

任何示例iPhone代码的模拟时钟?

有兴趣通过自己的模拟时钟应用程序创build – 谁知道一些示例项目/代码实现模拟时钟? (即不是数字时钟)。 理想情况下,自定义背景和自定义小时/分钟手作为图像? 我注意到,下面的链接存在,但希望有一些更具体的匹配我在做什么(背景图像,小时/分钟手的图像): 示例代码

在TableView中不正确的图像大小

我正在创build一个包含来自URL的图像的表格视图,但是图像不会重新调整到所有视图的大小,直到我将其预先设置在行中。 任何想法为什么发生? 这是一个自定义的tableview 我的代码是: – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString *CellIdentifier = @"Celula_Noticias"; Celula_Noticias *cell = (Celula_Noticias*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { NSArray * top= [[NSBundle mainBundle] loadNibNamed:@"Celula_Noticias" owner:self options:nil]; for(id currentObject in top){ if ([currentObject isKindOfClass:[Celula_Noticias class]]) { cell= (Celula_Noticias *) currentObject; break; } } } cell.Image_Noticias_1.image=[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[[noticias objectAtIndex:indexPath.row […]

如何裁剪UIImageView到自定义形状

用户是否可以在他们希望裁剪的UIImageView的位周围绘制一条虚线(围成一圈),然后让UIImageView调整到这些点的位置? 这有点像Photoshop中的套索/字幕效果: