摘要:Hi David -Here's a relatively simple approach. Just create an NSAttributedString with the appropriate font and ask for its size:- (CGFloat)widthOfString:(NSString *)string withFont:(NSFont *)font { NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:font, NSFontAttributeName, n
阅读全文
摘要:ref:http://blog.csdn.net/pjk1129/article/details/6946724CALayer(层)是屏幕上的一个矩形区域,在每一个UIView中都包含一个根CALayer,在UIView上的所有视觉效果都是在这个Layer上进行的。CALayer外形特征主要包括:1、层的大小尺寸2、背景色3、内容(可以填充图片或者使用Core Graphics绘制的内容)4、矩形是否使用圆角5、矩形是否有阴影Layer有很多种,最常用也是最基本的是CALayer,当然还包括其他的子类:CAScrollerLayer 简化显示层的一部分CATextLayer 文本层CAGrad
阅读全文
摘要:Ref:http://www.cnblogs.com/ygm900/archive/2013/05/24/3098015.htmliphone4/4s 应用程序升级适配 iphone5 的方法有很多,而且其中原理在网上也找的到。本次废话不多说,单简要叙述我的过程:综合权衡,我选择用增加xib文件的方法。第一步:为需要适配找到工程中需要适配iphone5的xib文件,加入是AViewController。首先,到工程文件目录下,找到AViewController.xib文件,然后在同一文件夹下拷贝一份,重命名为AViewController_ip5.xib 文件。第二步:将AViewContro
阅读全文
摘要:苹果官方文档中的写法static AccountManager *DefaultManager = nil; + (AccountManager *)defaultManager { if (!DefaultManager) DefaultManager = [[self allocWithZone:NULL] init]; return DefaultManager;} 在iOS4之后有了另外一种写法+ (AccountManager *)sharedManager{ static AccountManager *sharedAccountManagerInsta...
阅读全文
摘要:1 添加AddressBook.framewor AddressBookUI.framework2#import #import 3 检查授权// iOS 6-(bool)checkAddressBookAuthorizationStatus:(UITableView*)tableView;{ ABAuthorizationStatus authStatus = ABAddressBookGetAuthorizationStatus(); if (authStatus != kABAuthorizationStatusAuthorized) { ...
阅读全文
摘要://// MovableImageView.h//#import @interface MovableImageView : UIImageView@end //// MovableImageView.m//#import "MovableImageView.h"@implementation MovableImageView- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ [super touchesBegan:touches withEvent:event];}-(void)touches
阅读全文
摘要:-(UIImage *)saveImage:(UIView *)view withRect:(CGRect) mainRect // mainRect 应该是相对于屏幕的Rect{ UIGraphicsBeginImageContext(mainRect.size); CGContextRef context = UIGraphicsGetCurrentContext(); [[UIColor blackColor] set]; CGContextFillRect(context, mainRect); [view.layer renderInContext:co...
阅读全文
摘要:1 添加MessageUI.framework2#import - (IBAction)doEmailBtn:(id)sender{ MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init]; mailController.mailComposeDelegate = self; [mailController setToRecipients:@[@"zxm@xxxxxx.com"]]; [mailController setSubject:@"M
阅读全文
摘要:- (UIImage *)imageForState:(UIControlState)state;- (UIImage *)backgroundImageForState:(UIControlState)state;// 示例[sender imageForState:UIControlStateNormal];
阅读全文
摘要:从图片库获取数据- (IBAction)doPhotoAlbumBtn:(UIButton *)sender { UIImagePickerController* ipController = [[UIImagePickerController alloc] init]; [self presentViewController:ipController animated:YES completion:nil]; [ipController setDelegate:self];}从相机获取数据UIImagePickerController* ipController = [[U...
阅读全文
摘要:if ([[[UIDevice currentDevice] model] rangeOfString:@"Sim"].location == NSNotFound) { // TODO} else { NSLog(@"iPhone Simulator can't use this funciton");}
阅读全文
摘要:- (UIImage*)imageWithImage:(UIImage*)image scaledToSize:(CGSize)newSize{ UIGraphicsBeginImageContext( newSize ); [image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)]; UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); ...
阅读全文
摘要:注意:在模拟器中无法模拟拨号NSString *phone = @"88888888";if (phone != nil) { NSString *telUrl = [NSString stringWithFormat:@"telprompt:%@",phone]; NSURL *url = [[NSURL alloc] initWithString:telUrl]; [[UIApplication sharedApplication] openURL:url];} UIWebView*callWebview =[[UIWebView alloc] in
阅读全文
摘要:#define BOOKLINK @"http://www.baidu.com"[[UIApplication sharedApplication] openURL:[NSURL URLWithString:BOOKLINK]];
阅读全文