發表文章

目前顯示的是 3月, 2011的文章

iphone程式開發 alert使用

圖片
iphone上很常見的警告視窗 如何使用呢 UIAlertView *alert=[[ UIAlertView alloc ]  initWithTitle : @"Alert!" message : @"Here is an alert message!" delegate : self cancelButtonTitle : @"OK" otherButtonTitles : nil ]   ; [alert show ]; [alert release ]; 要加入多個按鈕則使用"otherButtonTitles達成"     UIAlertView *alert = [[[ UIAlertView alloc ] initWithTitle : @"alert" message : @"Here is an alert message!" delegate : self cancelButtonTitle : @"1" otherButtonTitles : @" 2" , @" 3" , nil ] autorelease ]; [alert show ]; 執行如下 按下確定後的處理函式 可以透過delegate指派來達成 多個按鍵 會回傳buttonIndex 從0開始 然後再m檔裡實作 - ( void )alertView:( UIAlertView *)alertView didDismissWithButtonIndex:( NSInteger )buttonIndex { if (buttonIndex == 0 ) {     // and they clicked 1. NSLog ( @"1 clicked" );         } else if (buttonIndex== 1 ){ NSLog ( @"2 clicked" ); } else if (buttonInd...

IPHONE程式 UIColor

UIColor是常用在iOS裡的顏色函數 它提供了一些常用的顏色 如 orangeColor blackColor... 用法如下 Label . textColor = [ UIColor orangeColor ] ;  如果要取得它的rgb值 可以透過下面的方法 CGFloat R, G, B;     UIColor * uiColor = [ lblDate textColor ] ; CGColorRef color = [ uiColor CGColor ] ;   int numComponents = CGColorGetNumberOfComponents ( color ) ;     if ( numComponents == 4 ) {   const CGFloat * components = CGColorGetComponents ( color ) ;   R = components [ 0 ] ;   G = components [ 1 ] ;   B = components [ 2 ] ;   } 如果想設定UIColor的自定RGB色彩 float r,g,b;   r=100;   g=255;   b=255;   testLabel . textColor = [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1]; 再這裡要注意的一點是 UIColor裡的RGB值是以0~1輸入 不是0~255喔