Proficient in iOS Development Sixth Edition, Chapter One, examples and exercises in the article.

Source: Internet
Author: User

Chapter I.

1 #import "ViewController.h"2 3 @interfaceViewcontroller ()4 5 @end6 7 @implementationViewcontroller8 9 Ten-(Ibaction) buttonpressed: (UIButton *) Sender { One     //Remove the title of the button ANSString *title =[Sender Titleforstate:uicontrolstatenormal]; -      -     //use the removed title format as a string and assign a value to the new NSString object theNSString *plaintext = [NSString stringWithFormat:@"pressing%@ button", title]; -      - //_statuslabel.text = plaintext; //assigns a formatted string to the label's Text property -      +     //variable string attribute class, creating object -Nsmutableattributedstring *textstyle =[[nsmutableattributedstring alloc]initwithstring:plaintext]; +      A     //nsdictionary dictionary new Syntax @{} is used to save string properties: Nsarray array new syntax is @[] atNsdictionary *dict = -     @{ - Nsfontattributename:[uifont Boldsystemfontofsize:_statuslabel.font.pointsize] -       }; -      -     //remove the substring to be changed in the plaintext string that is the title can also use @ "" to remove other strings inNsrange Namerange =[plaintext Rangeofstring:title]; -      to     //sets the string property. + [TextStyle setattributes:dict range:namerange]; -      the_statuslabel.attributedtext =TextStyle; *      $     Panax Notoginseng } - @end

Proficient in iOS Development Sixth Edition, Chapter One, examples and exercises in the article.

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.