Key code for the host controller:
Viewcontroller.m
#import "ViewController.h"@interfaceViewcontroller () @property (weak, nonatomic) Iboutlet Uitextview*TEXTF;@end@implementationViewcontroller- (void) viewdidload {[Super viewdidload]; //1. Create a row of background imagesCGFloat ROWW =Self.view.frame.size.width; CGFloat ROWH= +; Uigraphicsbeginimagecontextwithoptions (Cgsizemake (ROWW, ROWH), NO,0.0); //Draw a rectangular boxCgcontextref CTX =Uigraphicsgetcurrentcontext (); [[Uicolor Whitecolor]Set]; Cgcontextaddrect (CTX, CGRectMake (0,0, ROWW, ROWH)); Cgcontextfillpath (CTX); //2. Draw the line[[Uicolor Blackcolor]Set]; CGFloat linewidth=1; Cgcontextsetlinewidth (CTX, linewidth); CGFloat Dividerx=Ten; CGFloat Dividery= ROWH-linewidth; Cgcontextmovetopoint (CTX, Dividerx, dividery); Cgcontextaddlinetopoint (CTX, Roww-Dividerx, Dividery); Cgcontextstrokepath (CTX); //3. Take a pictureUIImage *newimage =Uigraphicsgetimagefromcurrentimagecontext (); //4. End ContextUigraphicsendimagecontext (); //5. Setting the backgroundSelf.textF.backgroundColor =[Uicolor Colorwithpatternimage:newimage]; }-(void) imagebg{UIImage*oldimage = [UIImage imagenamed:@"Me"]; Uigraphicsbeginimagecontextwithoptions (Self.view.frame.size, NO,0.0); [Oldimage DrawInRect:self.view.bounds]; UIImage*newimage =Uigraphicsgetimagefromcurrentimagecontext (); Uigraphicsendimagecontext (); Self.view.backgroundColor=[Uicolor colorwithpatternimage:newimage];}@end
iOS Dev _ stripe background