objective c - what is the meaning of + symbol in iOS file naming? -
this question has answer here:
- class name “+” 2 answers
i have seen examples of ios project, little confused naming rule of file. meaning of + symbol in ios naming rule? in case should use symbol.
and mean put draggle within ().
hopefully can help. thank much.
those categories
the "draggable" category of uicollectionview
here's snippent apple:
if need add method existing class, perhaps add functionality make easier in own application, easiest way use category.
the syntax declare category uses @interface keyword, standard objective-c class description, not indicate inheritance subclass. instead, specifies name of category in parentheses, this:
@interface classname (categoryname) @end
here's example
#import "uiview+roundify.h" @implementation uiview (roundify) -(void)addroundedcorners:(uirectcorner)corners withradii:(cgsize)radii { calayer *tmasklayer = [self maskforroundedcorners:corners withradii:radii]; [[self layer] setmask:tmasklayer]; } -(calayer*)maskforroundedcorners:(uirectcorner)corners withradii:(cgsize)radii { cashapelayer *masklayer = [cashapelayer layer]; masklayer.frame = self.bounds; uibezierpath *roundedpath = [uibezierpath bezierpathwithroundedrect: masklayer.bounds byroundingcorners:corners cornerradii:radii]; masklayer.fillcolor = [[uicolor whitecolor] cgcolor]; masklayer.backgroundcolor = [[uicolor whitecolor] cgcolor]; masklayer.path = [roundedpath cgpath]; return masklayer; } @end
header
@interface uiview (roundify) -(void)addroundedcorners:(uirectcorner)corners withradii:(cgsize)radii; -(calayer*)maskforroundedcorners:(uirectcorner)corners withradii:(cgsize)radii; @end
this means when import file, can call method "addroundcorners" uiview
Comments
Post a Comment