During the development of iOS, we may sometimes use Uicolor * color= [Uicolor colorwithpatternimage:image];
Sometimes the background image appears incomplete or the background image is displayed as multiple images instead of a whole picture.
At this point we need to enlarge or reduce the size of the image to the size of the view to achieve the full background picture.
Here's how:
UIImage *matchimg = [UIImage imagenamed:@ "You need to be a picture of the background"]; UIImage *backimage; CGFloat width = self.view.frame.size.width;//Self.view Indicates the size of your view cgfloat height = self.view.frame.size.height; Uigraphicsbeginimagecontext (Cgsizemake (width, height)); [Matchimg drawinrect:cgrectmake (0, 0, width, height)];//adjustment backimage = Uigraphicsgetimagefromcurrentimagecontext (); Uigraphicsendimagecontext (); Self.view.backgroundColor = [Uicolor colorwithpatternimage:backimage];//This enables full screen display of the background picture
iOS background image size inconsistency problem