First:
This uiview can write:
-(ID) initWithFrame: (CGRect) frame backimage: (uiimage*) Image msgStr: (nsstring*) txt txtcolor: (uicolor*) color{sel f = [Super Initwithframe:frame]; if (self) {self.backgroundcolor = [uicolor Clearcolor]; _paopaoimage = image; _txt = txt; _color = color; } return self;} Only override Drawrect:if-perform custom drawing.//an empty implementation adversely affects performance during a nimation.-(void) DrawRect: (cgrect) rect{cgcontextref context = Uigraphicsgetcurrentcontext (); CGRect textrc = rect; [_paopaoimage Drawinrect:rect]; Cgfontref Contextfont = Cgfontcreatewithfontname ((cfstringref) [Uifont Systemfontofsize:14].fontname]; Cfrelease (Contextfont); Cgcontextsetfontsize (context, 14.0); Cgcontextsetfillcolorwithcolor (context, _color. Cgcolor); TEXTRC.ORIGIN.Y + = 11.0f; [_txt drawinrect:textrc Withfont:[uifont systemfontofsize:14] linebreakmode:nslinebreakbywordwrapping alignment: NstextalignmentcentER];}
And then pops up:
-(void) showtipview{ cgrect rect = [[Homepageuimanager sharedinstance] categorytipviewframewhenlaunch]; popupmenu* menu = [[PopupMenu alloc] initwithframe:rect backimage:[uiimage imagenamed:@ "Change_search_tip.png"] msgStr : @ "open/close Panel" Txtcolor:[ccommon rgbcolorfromhexstring:@ "#ffffff" alpha:1.0f]; [Self.view Addsubview:menu]; Cabasicanimation *jumpanimation = [cabasicanimation animationwithkeypath:@ "TRANSFORM.TRANSLATION.Y"]; Jumpanimation.fromvalue = [NSNumber numberwithfloat:0.0f]; Jumpanimation.tovalue = [NSNumber numberwithfloat:8.0f]; jumpanimation.duration = 0.5f;//Animation duration Jumpanimation.repeatcount = 10;//animation repeat times jumpanimation.autoreverses = yes;//whether to take the initiative repeatedly [Menu.layer addanimation:jumpanimation forkey:@ "Animatelayer"];}
The code can be downloaded in http://download.csdn.net/detail/baidu_nod/7629687
iOS assumes that writing a hint-driven view of the picture can guide user behavior