4

How to make collage of images in iPhone. I've given the image and there are different shapes in the bottom, according to these shapes i want to change the images. So please help me any one. It will be very thankful and i will really appreciate your effort and help. Thanks a lot.......

And i've tried these link How to make a view resize on swipe within a photo collage for iOS?

enter image description here

Community
  • 1
  • 1
Dharmbir Singh
  • 17,485
  • 5
  • 50
  • 66

1 Answers1

3

I just put my logic.

  • your view has been display 4 images (with different shape) so you need to take 4 UIImageView in .h file and one UIView name is ImgContainerView in .h file
  • make sure that your all button has same action method and give all button to it's tag. for example each button has method name is

    -(void) buttonMethodName:(UIButton *) sender

  • Then you need to create one method name is,

    -(void)setUpimagesByselectedButton:(int) buttonTag

Call this method in button's action method, such like

-(void) buttonMethodName:(UIButton *) sender           
{
  [self setUpimagesByselectedButton:sender.tag]; // pass button's tag as parameter.
}

Here now in method,

-(void)setUpimagesByselectedButton:(int) buttonTag
{
  // first you need to remove all subview of ImgContainerView 
  if(self.ImgContainerView)
  {
    for(UIView *subview in self.ImgContainerView.subviews)
        [subview removeFromSuperview];
    [self.ImgContainerView removeFromSuperview]; self.ImgContainerView = nil;
  }
  // Then re-create  ImgContainerView with background color is white;
  // add all UIImageView as subView of ImgContainerView;
  // and then set FRAME of your UIImageView base on selected button's tag such like.
  if(buttonTag == 1)// for ex. i take 1, here you write your button's tag.
    self.imageView1.frame....
  // create one by one imageView and set it's frame by put condition as above       
  // your UIImageView's contentMode should be  UIViewContentModeScaleAspectFill or UIViewContentModeCenter;
}

When you tap any button then each time ImgContainerView is re-created with it's particular shape.

iPatel
  • 46,010
  • 16
  • 115
  • 137
  • Thanks a lot for your quick response but dude image can be less or more then 4 and shapes also can vary. So please help me in this scenario. I already thought your solution but its not according to my requirement. But again really very glad to see your quick response. – Dharmbir Singh Feb 07 '14 at 05:47
  • Logic is same you need to set dynamically frame of each ImageView as per your requirement. and how can you recognize shape ?? – iPatel Feb 07 '14 at 05:54
  • You mean i've to manage dynamically, no one is other solution.i think its too complex coz suppose i've selected 10 images and then there are 9 shapes and then i've to make it programmatically right ? – Dharmbir Singh Feb 07 '14 at 06:04
  • @DharmbirChoudhary - No there are many solution may be, but i thinking bout it :) in all case/solution you must need to know about shape otherwise how can you set images ?? And YES you need to set dynamically frame of each ImageView base on shape. and really your question is fine and interested :) – iPatel Feb 07 '14 at 06:08
  • If you don't mind can you see collage in this app https://itunes.apple.com/us/app/streamzoo-public-private-group/id421025926?mt=8 . I want the same as in this app. Thanks – Dharmbir Singh Feb 07 '14 at 06:11
  • I already understand your question.. but i want to know how can you recognize your shape? *(you told me that shape is not fix so..)* – iPatel Feb 07 '14 at 06:14
  • I'll recognise according to image length like if image = 1 then shape = 2, image = 2 then shape = 5 ,image = 3 then shape = 6, image 4 then shape = 9 ,image = 5 then shape = 5, image = 6 then shape = 5 ,image = 7 then shape = 4, image 8 then shape = 3 , image = 9 then shape = 3. – Dharmbir Singh Feb 07 '14 at 06:19
  • Ok Then If image = 7 then shape = 4 then i want to know about arrangement design/flow of 7 images in specific shape *(which type of 4 shape will be ? or how can you get it or create it)*. – iPatel Feb 07 '14 at 06:28
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/46989/discussion-between-dharmbir-choudhary-and-ipatel) – Dharmbir Singh Feb 07 '14 at 06:30