-(void) addstripe
{
[Super Viewdidload];
Self.view.backgroundColor = [Uicolor Redcolor];
1. Create a row of background images
CGFloat ROWW = self.view.frame.size.width;
CGFloat ROWH = 40;
CGFloat ROWH = 30;
Uigraphicsbeginimagecontextwithoptions (Cgsizemake (ROWW, ROWH), NO, 0.0);
Cgcontextref CTX = Uigraphicsgetcurrentcontext ();
Draw a rectangular box
[[Uicolor Redcolor] set];
Cgcontextaddrect (CTX, cgrectmake (0, 0, ROWW, ROWH));
Cgcontextfillpath (CTX);
2. Draw the Line
[[Uicolor Greencolor] set];
CGFloat linewidth = 2;
Cgcontextsetlinewidth (CTX, linewidth);
CGFloat Dividerx = 0;
CGFloat dividery = rowh-linewidth;
Cgcontextmovetopoint (CTX, Dividerx, dividery);
Cgcontextaddlinetopoint (CTX, Roww-dividerx, dividery);
Cgcontextstrokepath (CTX);
3. Take a picture
UIImage *newimage = Uigraphicsgetimagefromcurrentimagecontext ();
4. End Context
Uigraphicsendimagecontext ();
5. Set as Background
Self.textView.backgroundColor = [Uicolor colorwithpatternimage:newimage];
}
iOS Add stripe background