I'm uring iCarossel with SDWebImage. Everything works just fine but when the image size is too big it just goes out of the screen.
Following is the snippet where image view is generated
view = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
[((UIImageView *)view) setImageWithURL:[NSURL URLWithString:@"http://www.pizzatower.com/img/icons/Pizza-icon.png"]];
// [((UIImageView *)view) setImageWithURL:[NSURL URLWithString:@"http://www.rivercitypizza.com/PepperoniPizza-full.jpg"]];
view.contentMode = UIViewContentModeCenter;
view.frame = CGRectMake(0, 0, 256, 256);
label = [[UILabel alloc] initWithFrame:view.bounds];
label.backgroundColor = [UIColor clearColor];
label.font = [label.font fontWithSize:10];
label.tag = 1;
[view addSubview:label];
I tried changint the frame
attribute but nothing changes. Could someone point me out how to resize the image and keep it within the size of the screen?
If you use
view.contentMode = UIViewContentModeScaleAspectFit;
your image will be scaled to fit inside the frame.