在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,91精品国产91免费

<menu id="6qfwx"><li id="6qfwx"></li></menu>
    1. <menu id="6qfwx"><dl id="6qfwx"></dl></menu>

      <label id="6qfwx"><ol id="6qfwx"></ol></label><menu id="6qfwx"></menu><object id="6qfwx"><strike id="6qfwx"><noscript id="6qfwx"></noscript></strike></object>
        1. <center id="6qfwx"><dl id="6qfwx"></dl></center>

            新聞中心

            EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > iphone開發(fā)中的一些小技巧

            iphone開發(fā)中的一些小技巧

            作者: 時間:2016-10-08 來源:網(wǎng)絡(luò) 收藏

            1、如果在程序中想對某張圖片進(jìn)行處理的話(得到某張圖片的一部分)可一用以下代碼:

            本文引用地址:http://www.biyoush.com/article/201610/305924.htm

            UIImage *image = [UIImage imageNamed:filename];

            CGImageRef imageRef = image.CGImage;

            CGRect rect = CGRectMake(origin.x, origin.y ,size.width, size.height);

            CGImageRef imageRefRect = CGImageCreateWithImageInRect(imageRef, rect);

            UIImage *imageRect = [[UIImage alloc] initWithCGImage:imageRefRect];

            2、判斷設(shè)備是iphone還是iphone4的代碼:

            #define isRetina ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)

            3、判斷郵箱輸入的是否正確:

            - (BOOL) validateEmail: (NSString *) candidate {

            NSString *emailRegex = @[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+.[A-Za-z]{2,4};

            NSPredicate *emailTest = [NSPredicate predicateWithFormat:@SELF MATCHES %@, emailRegex];

            return [emailTest evaluateWithObject:candidate];

            }

            4、如何把當(dāng)前的視圖作為照片保存到相冊中去:

            #import

            UIGraphicsBeginImageContext(currentView.bounds.size); //currentView 當(dāng)前的view

            [currentView.layer renderInContext:UIGraphicsGetCurrentContext()];

            UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();

            UIGraphicsEndImageContext();

            UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);

            5、本地通知(類似于push通知)按home鍵到后臺 十秒后觸發(fā):

            UILocalNotification *notification=[[UILocalNotification alloc] init];

            if (notification!=nil) {

            NSLog(@>> support local notification);

            NSDate *now=[NSDate new];

            notification.fireDate=[now addTimeInterval:10];

            notification.timeZone=[NSTimeZone defaultTimeZone];

            notification.alertBody=@該去吃晚飯了!;

            [[UIApplication sharedApplication].scheduleLocalNotification:notification];

            }

            6、捕獲iphone通話事件:

            CTCallCenter *center = [[CTCallCenter alloc] init];

            center.callEventHandler = ^(CTCall *call)

            {

            NSLog(@call:%@, call.callState);

            }

            7、iOS 4 引入了多任務(wù)支持,所以用戶按下 “Home” 鍵以后程序可能并沒有退出而是轉(zhuǎn)入了后臺運(yùn)行。如果您想讓應(yīng)用直接退出,最簡單的方法是:在 info-plist 里面找到 Application does not run in background 一項,勾選即可。

            8、使UIimageView的圖像旋轉(zhuǎn):

            float rotateAngle = M_PI;

            CGAffineTransform transform =CGAffineTransformMakeRotation(rotateAngle);

            imageView.transform = transform;

            9、設(shè)置旋轉(zhuǎn)的原點(diǎn):

            #import

            UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@bg.png]];

            imageView.layer.anchorPoint = CGPointMake(0.5, 1.0);

            10、實現(xiàn)自定義的狀態(tài)欄(遮蓋狀態(tài)欄):

            CGRect frame = {{0, 0}, {320, 20}};

            UIWindow* wd = [[UIWindow alloc] initWithFrame:frame];

            [wd setBackgroundColor:[UIColor clearColor]];

            [wd setWindowLevel:UIWindowLevelStatusBar];

            frame = CGRectMake(100, 0, 30, 20);

            UIImageView* img = [[UIImageView alloc] initWithFrame:frame];

            [img setContentMode:UIViewContentModeCenter];

            [img setImage:[UIImage imageNamed:@00_0103.png]];

            [wd addSubview:img];

            [wd makeKeyAndVisible];

            [UIView beginAnimations:nil context:nil];

            [UIView setAnimationDuration:2];

            frame.origin.x += 150;

            [img setFrame:frame];

            [UIView commitAnimations];

            11、在程序中實現(xiàn)電話的撥打:

            //添加電話圖標(biāo)按鈕

            UIButton *btnPhone = [[UIButton buttonWithType:UIButtonTypeCustom] retain];

            btnPhone.frame = CGRectMake(280,10,30,30);

            UIImage *image = [UIImage imageNamed:@phone.png];

            [btnPhone setBackgroundImage:image forState:UIControlStateNormal];

            //點(diǎn)擊撥號按鈕直接撥號

            [btnPhone addTarget:self action:@selector(callAction:event:)forControlEvents:UIControlEventTouchUpInside];

            [cell.contentView addSubview:btnPhone]; //cell是一個UITableViewCell

            //定義點(diǎn)擊撥號按鈕時的操作

            - (void)callAction:(id)sender event:(id)event{

            NSSet *touches = [event allTouches];

            UITouch *touch = [touches anyObject];

            CGPoint currentTouchPosition = [touch locationInView:self.listTable];

            NSIndexPath *indexPath = [self.listTable indexPathForRowAtPoint: currentTouchPosition];

            if (indexPath == nil) {

            return;

            }

            NSInteger section = [indexPath section];

            NSUInteger row = [indexPath row];

            NSDictionary *rowData = [datas objectAtIndex:row];

            NSString *num = [[NSString alloc] initWithFormat:@tel://%@,number]; //number為號碼字符串

            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:num]]; //撥號

            }

            12、更改iphone的鍵盤顏色:


            上一頁 1 2 下一頁

            關(guān)鍵詞:

            評論


            相關(guān)推薦

            技術(shù)專區(qū)

            關(guān)閉