iOS Dev _ stripe background

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.