iOS常用之imageview和scrollView显示长图片

-(void)addImageOnViewWithImage:(NSString *)imageStr{

    UIScrollView *scroll=[[UIScrollViewalloc]initWithFrame:self.view.frame];

    scroll.showsVerticalScrollIndicator=NO;

    [self.viewaddSubview:scroll];

    CGFloat imageH;

    UIImage *image;

   

    image=[UIImage imageNamed:@"hehuoren"];

    imageH=image.size.height;

    if(WIDTH==320){

        image=[UIImage imageNamed:@"hehuorenSe"];

        imageH=image.size.height;

        

    }else if(HEIGHT==812){//适配iphoneX

        

        image=[UIImage imageNamed:@"hehuorenPX"];

        imageH=image.size.height;

    }

    scroll.contentSize=CGSizeMake(0, imageH+50);

    UIImageView *  imagev=[[UIImageViewalloc]initWithFrame:CGRectMake(0,0,WIDTH, imageH)];

    imagev.image=image;

    [scroll addSubview:imagev];

    

}

你可能感兴趣的:(iOS/oc)