How to “cascade” image pattern in UIImageView?

前端 未结 1 1855
你的背包
你的背包 2021-02-05 18:04

I have an image pattern which I want to display in a UIImageView. The UIImageVIew\'s size is determined by user-entered text, so its height will change. Is there a way to \"casc

相关标签:
1条回答
  • 2021-02-05 18:48

    You should be able to accomplish this with a plain UIView. Create a UIColor from the image (this makes a "pattern image", which can be tiled:

    UIColor *patternColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"pattern"]];
    

    Then set the background color of the view like so:

    view.backgroundColor = patternColor;
    

    I'd run this code in the viewDidLoad or viewWillAppear methods of the view's controller.

    0 讨论(0)
提交回复
热议问题