drawRect / Instagram_Stories

Inspired by Instagram Stories functionality. This source is similar to Instagram Stories, which is having both image and video support.
MIT License
415 stars 76 forks source link

Images are stretched #79

Closed forTJ555 closed 4 years ago

forTJ555 commented 4 years ago

Simulator Screen Shot - iPhone Xʀ - 2019-10-24 at 15 39 24 Describe the bug when we upload images and show it from url using api's it looks stretched how we can fix this?

boominadhaprakash commented 4 years ago

Hi,

Images stretched means change image view content property mode to aspect fit.

Regards, Boominadha Prakash

forTJ555 commented 4 years ago

but from where do i get image property from stories view

ranmyfriend commented 4 years ago

Hi @forTJ555 Kindly look at IGStoryPreviewCell and line number: 172. There is a method called createSnapView(). Here you can get the respective individual image view. Try to change the AspectFit for this image view and let us know

Thanks, Ranjith

forTJ555 commented 4 years ago

yes it works perfectly now, thanks for your help @ranmyfriend

forTJ555 commented 4 years ago

is there any way to make background white? i was set background color of image to black but it did not work @ranmyfriend

ranmyfriend commented 4 years ago

@forTJ555 See the image is there in scrollView and scrollView is there in IGStoryPreviewCell. try to change the background colour of the cell. Like cell.contentView and see or try to change it to scroll view background colour.

forTJ555 commented 4 years ago

@ranmyfriend both are not work neither scroll view backround nor cell.content view background color

ranmyfriend commented 4 years ago

Hmm. Actually the image view is completely stretched to scroll view. that's why even if we set a different colour to the content view and scroll view also not reflecting.

forTJ555 commented 4 years ago

is there any other way to make to black?

ranmyfriend commented 4 years ago

@forTJ555 instead of giving the ImageView.height equal to scroll view.height. you just try to give image.size.height but it should not be exceed with scroll view.height. once you apply this logic, then your scroll view area will get visible automatically. then you just set the background colour of scroll view. By then Automatically it will get visible. or try to set the image height in 9:16 Aspect Ratio. I hope it will work. Let me know once you have fixed it.

forTJ555 commented 4 years ago
        snapView.heightAnchor.constraint(equalTo: snapView.heightAnchor),

did this and set scroll view background color black. but its not working well

ranmyfriend commented 4 years ago

See you should update the Height Anchor constant with Image size.height. Once you get downloaded requested image, get the size of the image and set it to the Height Anchor of snapView. then it will work.

boominadhaprakash commented 4 years ago

Hi @forTJ555

If you want to set any backgroundColor, apply backgroundColor where we are creating the views. For example if you want to set background color for ScrollView, set background color for ScrollView which we are generating on IGStoryPreviewCell.

Please attach any sample screenshot of how do you want to display the image. So that we can guide you in better way.

Regards, Boominadha Prakash

forTJ555 commented 4 years ago

Simulator Screen Shot - iPhone 6 - 2019-11-14 at 21 16 46

background shows white when image set as scaleAspectFit snapView.contentMode = .scaleAspectFit

boominadhaprakash commented 4 years ago

@forTJ555 Have you tried to set background color for cell?

fadeev-vitaliy commented 4 years ago

I found solution Set background color in IGImageRequestable extension after set image

Снимок экрана 2019-11-20 в 10 40 53

I found solution to get average color of image, and set it to background solution here https://www.hackingwithswift.com/example-code/media/how-to-read-the-average-color-of-a-uiimage-using-ciareaaverage It looks beautiful

ranmyfriend commented 4 years ago

@fadeev-vitaliy You are awesome :) Thanks.

@forTJ555 can you please try to implement what he mentioned and let us know.

forTJ555 commented 4 years ago

yes it works perfect. Thanks for the great library :)

boominadhaprakash commented 4 years ago

Hi @forTJ555

Glad to hear that your issue has been resolved.

Regards, Boominadha Prakash