Repeat image horizontally and vertically

前端 未结 5 1411
刺人心
刺人心 2020-12-05 05:29

I want to repeat the following image:

\"enter

to achieve the following backgro

5条回答
  •  爱一瞬间的悲伤
    2020-12-05 05:43

    As my comment already said: use

    bluePatternView.backgroundColor = 
      [UIColor colorWithPatternImage:[UIImage imageNamed:@"blue_pattern.png"]];
    

    You dont want to stretch your image. Let UIKit take care of the repetition.

    Assuming that your bluePatternView is the actual large view for which you want to set a pattern as background. Maybe you are setting the background property of the wrong view if that code is still not working.

    Note: duplicating the SAME image with @2x and @3x extension will lead to behaive properly for better resolution devices.

    enter image description here

提交回复
热议问题