uiimageview

Exchange position of cells by gesture

随声附和 提交于 2020-01-04 01:53:16
问题 I have UICollectionView in which I have a prototype cell and UIImageView in it.I am displaying random images in UICollectionView . Now I want to exchange position of UIImageView by swiping it to near cell.I have tried swipe gesture and long press gesture.Code is given below which I have done: - (IBAction)LongPress:(UILongPressGestureRecognizer *)sender { if (sender.state != UIGestureRecognizerStateEnded) { return; } CGPoint p = [sender locationInView:self.collectionView]; NSIndexPath

CollectionView with background Image

和自甴很熟 提交于 2020-01-04 00:31:48
问题 I use collectionView with a transparent background and imageView under the CollectionView. I change the ImageView depending on the cell that is in the middle, but the image are not displayed correctly, how you can solve it, an example of how it should look and looks below Gif: how it should work: how it works: func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionViewRecomend.dequeueReusableCell

CollectionView with background Image

安稳与你 提交于 2020-01-04 00:31:33
问题 I use collectionView with a transparent background and imageView under the CollectionView. I change the ImageView depending on the cell that is in the middle, but the image are not displayed correctly, how you can solve it, an example of how it should look and looks below Gif: how it should work: how it works: func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionViewRecomend.dequeueReusableCell

How to make text appear in centre of the image?

五迷三道 提交于 2020-01-03 05:50:10
问题 I want to add a text on an image, and I'm able to do it as shown in below code. func textToImage(drawText: NSString, inImage: UIImage, atPoint:CGPoint)->UIImage{ // Setup the font specific variables var textColor: UIColor = UIColor.redColor() var textFont: UIFont = UIFont(name: "AmericanTypewriter", size: 75)! let textStyle = NSTextEffectLetterpressStyle //Setup the image context using the passed image. UIGraphicsBeginImageContext(inImage.size) let textFontAttributes = [ NSFontAttributeName:

UIImageView not updating with new image after picture taken or picture chosen from photo library

不问归期 提交于 2020-01-03 05:19:45
问题 I'm trying to populate an image within a UIImageView after I either take a picture or choose a picture from my photo library. here is the code handling the camera and photo library activations: @IBAction func activateCmera(_ sender: Any) { if (UIImagePickerController.isSourceTypeAvailable(.camera)) { let imagePicker = UIImagePickerController() imagePicker.delegate = self imagePicker.sourceType = .camera imagePicker.allowsEditing = false self.present(imagePicker, animated: true, completion:

Adding individual UIImageViews for each item in an array

微笑、不失礼 提交于 2020-01-03 05:09:09
问题 I am trying to add a individual UiImageView for each item in an array this is what I have so far _shapeArray = [NSArray arrayWithObjects:@"cloud.png",@"star.png", nil]; for (int i = 0; i < [_shapeArray count]; i++){ // I make a UIImage, which I will draw later UIImage* image = [UIImage imageNamed:[NSString stringWithFormat:@"%@",[_shapeArray objectAtIndex:i]]]; UIImageView* blockView = [[UIImageView alloc] initWithImage:image]; blockView.frame = CGRectMake(arc4random()%320, arc4random()%460,

How to identify touch on a specific imageView from multiple imageViews in a UIScrollView?

纵饮孤独 提交于 2020-01-03 03:12:07
问题 I have multiple ImageViews in a UIScrollView and I want to identify the specific imageView on which I touched . So that I could do some actions. (for example, showing Alert with the image name). I have seen some similar posts, but they did not have proper answer. And some answers were complex to me as I am pretty new to iPhone programming. It would be great, If anybody helps with a simple example. :-) my code is like this - (void)viewDidLoad { imgScrollView.userInteractionEnabled =YES; //

UIView Frame Size Didn't Change UIImageView Placed inside it

你离开我真会死。 提交于 2020-01-02 19:30:10
问题 I'm making a picture in a frame and then user can resize the frame size in runtime. For this purpose I've made a custom UIView in my main UIViewController and inside this UIView I've placed 2 UIImageView . In Document Outline Pane of xCode it's hierarchy is: View |--ImageView |--ImageView I'm using this line of code to change size of UIView under different conditions it'll resize accordingly: self.imageObject.frame = CGRectMake(self.imageObject.frame.origin.x , self.imageObject.frame.origin.y

Creating subclass of UIImageView

独自空忆成欢 提交于 2020-01-02 14:47:10
问题 I havent found the option of UIImageView to choose from dropdown during creating objective-c class. I am using xcode 4.3. I want to know arent we allowed to extend UIImageView class. Or do i have to inherit UIView ? Any sample structure of custom UIImageView class would be helpful. Thanks 回答1: I believe it's considered bad practice to subclass UIImageView. If you take a look at this question, there are many examples of why you shouldn't do it: A part of the Gang of Fours design pattern

Strange UITableViewCellStyleSubtitle + [cell imageView] behaviors

狂风中的少年 提交于 2020-01-02 11:23:47
问题 This question's been bugging me for a month and i've been resisting posting about it, but I can hold out no longer. Here's what's going on: I have an app with UITableViewCell s, all initialized as UITableViewCellStyleDefault . For each one, I am setting the image view's image using the excellent SDWebImage package, which extends UIImageView to have a method for [UIImageView setImageWithURL:(NSURL*)url placeholderImage:(UIImage*)image]. The problem is that the images are showing up more narrow