
ios-基础
timtian008
让更多的程序员多一份管道收入
展开
-
iOS-Simulator设置模拟定位
1、模拟器设置:Debug - Location - City Bicycle Ride 设置当前位置2、模拟器设置 :Debug - Location - Custom Location 设置模拟坐标定位Latitude: 纬度 Longitude: 经度...原创 2018-12-21 14:34:32 · 7597 阅读 · 0 评论 -
ios-设置状态栏样式 [UIApplication sharedApplication].statusBarStyle
在info.plist文件中添加一个属性View controller-based status bar appearance,设置为No(不支持在文件中设置状态栏样式)然后在AppDelegate中写上[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent,这样的话,全局的状态栏样式使用...原创 2018-12-07 21:06:02 · 3812 阅读 · 0 评论 -
设置视图部分圆角 + (instancetype)bezierPathWithRoundedRect:(CGRect)rect cornerRadius:(CGFloat)cornerRadius
设置视图部分圆角问题,只需要设置 layer.cornerRadius UIRectCorner有五种 UIRectCornerTopLeft //上左 UIRectCornerTopRight //上右 UIRectCornerBottomLeft // 下左 UIRectCornerBottomRight // 下右 UIRectCornerAllCorners // 全部...原创 2018-06-15 10:52:58 · 4000 阅读 · 0 评论 -
适配IPhone X相关宏定义
// MARK: 适配IPhone Xdefine AppStatusBarHeight [[UIApplication sharedApplication] statusBarFrame].size.height // 适配iPhone x 状态浪高度define AppSafeViewTopSpace AppStatusBarHeight+44define App...原创 2018-03-29 17:18:36 · 790 阅读 · 0 评论 -
IOS 快速查看系统键盘样式
typedef NS_ENUM(NSInteger, UIKeyboardType) { UIKeyboardTypeDefault, // Default type for the current input method. UIKeyboardTypeASCIICapable, // Displays a keyboard whi原创 2017-10-18 14:29:39 · 721 阅读 · 0 评论 -
IOS-UIActivityIndicatorView loading效果
属性值是一个枚举变量,只有三个值: UIActivityIndicatorViewStyleWhite; 白色圆圈,尺寸是(22,22)。 UIActivityIndicatorViewStyleWhiteLarge; 白色圆圈,但是要大些,尺寸是(37,37)。 UIActivityIndicatorViewStyleGray; 灰色圆圈,尺寸是(22,22)。 初始化UIActivit原创 2017-07-28 10:12:11 · 854 阅读 · 0 评论 -
ios - 设置文本中不同字体颜色
- (void)viewDidLoad {NSRange range = [orderPriceLabel.text rangeOfString:@"付款金额:"]; [self setTextColor:orderPriceLabel FontNumber:_kFontMain AndRange:range AndColor:kColor262626]; }//设置不同字体颜色原创 2017-07-26 13:55:12 · 646 阅读 · 0 评论 -
ios 判断是iphone还是ipad
在公共头文件中作如下定义:#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)#define IS_PAD (UI_USER_INTERFACE_IDIOM()== UIUserInterfaceIdiomPad)使用时:if( IS_IPHONE ) { // iphone处理}e原创 2017-07-23 23:17:33 · 10249 阅读 · 0 评论 -
IOS-处理父view alpha 等于0 导致全部透明的问题
UIView *view = [[UIView alloc] init];/*我们经常会这样设置,就会导致子视图也变成透明的了/ //是因为父view的alpha = 0 //view.alpha = 0;// 关键的是 alpha 要为 0可以直接设置view的backgroundColor来达到想要的效果 view.backgroundColor = [UIColor colorWithR原创 2017-07-17 22:24:44 · 1294 阅读 · 0 评论 -
ios webview自适应高度及关闭回弹效果
ios webview自适应高度及关闭回弹效果 //初始化,self.view是父控件 _webView = [[UIWebView alloc] initWithFrame: CGRectMake(0, 0, self.view.frame.size.width, 0)]; _webView.delegate = self; _webView.scrollView.bounces =原创 2017-07-12 20:48:53 · 3228 阅读 · 0 评论 -
ios webview自适应高度及关闭回弹效果
ios webview自适应高度及关闭回弹效果 //初始化,self.view是父控件 _webView = [[UIWebView alloc] initWithFrame: CGRectMake(0, 0, self.view.frame.size.width, 0)]; _webView.delegate = self; _webView.scrollView.bounces =原创 2017-07-12 20:48:43 · 1495 阅读 · 0 评论 -
iOS textfield限制输入的最大长度
iOS textfield限制输入的最大长度 [self.textFiled addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];-(void)textFieldDidChange:(UITextField *)textField{ CGFlo原创 2017-07-08 18:41:45 · 4613 阅读 · 0 评论 -
UITextView及UITextField处理键盘弹出 视图上移
#pragma -mark UITextView Delegate- (void)textViewDidEndEditing:(UITextView *)textView{ //输入框编辑完成,视图恢复到原始状态 self.view.frame = CGRectMake(0, 0, ScreenW, ScreenH);}-(void)textViewDidBeginEditing原创 2017-07-05 23:02:17 · 2850 阅读 · 0 评论 -
超好用!NSString 字符串处理:截取字符串、匹配字符串、分隔字符串 、分隔字符串
NSString 字符串处理:截取字符串、匹配字符串、分隔字符串 、分隔字符串 1.截取字符串NSString*string =@"sdfsfsfsAdfsdf";string = [string substringToIndex:7];//截取掉下标7之后的字符串NSLog(@"截取的值为:%@",string);[string substringFromIndex:2];//截取掉下标2原创 2017-05-25 18:49:44 · 1597 阅读 · 0 评论 -
Storyboard快速创建带有Navigation的Controller
步骤1:正常创建1个新项目 步骤2:选中默认创建的viewcontroller 步骤3:选择最上面工具栏的editor->embedin->navigation controller.同样的,想要创建一个带tabbar的页面也可以用这个套路,不同的是步骤3里面的最后一步,选择 tab bar controller原创 2017-05-10 23:06:30 · 714 阅读 · 0 评论 -
IOS---判断字符串是否为空
判断字符串是否为空- (BOOL)isBlankString:(NSString *)string { if (string == nil || string == NULL) { return YES; } if ([string isKindOfClass:[NSNull class]]) { return YES; } i原创 2017-04-06 11:43:28 · 636 阅读 · 0 评论 -
UITextField 快速实现缩进
下面是创建UITextField 快速实现缩进的方法-(UITextField*)titleTextField{ if (_titleTextField == nil) { _titleTextField = [[UITextField alloc]init]; _titleTextField.text =@"最美的产品,最真的诚意"; _ti原创 2017-03-17 17:03:38 · 1188 阅读 · 0 评论 -
UIDatePicker 基本设置-显示已经选择的日期 并设置最大、最小日期
// 1.日期Picker UIDatePicker *datePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 0, __kScreenWidth, __kDatePickerH)]; datePicker.backgroundColor = [UIColor whiteColor]; // 1.1选择da原创 2017-03-09 16:09:27 · 11494 阅读 · 0 评论 -
UIView 刷新---setNeedsDisplay、setNeedsLayout
ios layout机制相关方法(CGSize)sizeThatFits:(CGSize)size(void)sizeToFit ——————-(void)layoutSubviews(void)layoutIfNeeded(void)setNeedsLayout ——————–(void)setNeedsDisplay(void)drawRectlayoutSubviews在以原创 2017-02-25 17:01:26 · 5817 阅读 · 0 评论 -
一行代码搞定UIBarButtonItem里文字大小和颜色
修改UIBarButtonItem里文字颜色一行代码搞定: [self.navigationItem.rightBarButtonItem setTintColor:[UIColor whiteColor]];但如果想修改文字的尺寸 阴影等其他复杂效果是就找不到直接的修改方法了 但可以通过下面的方法做到:[self.navigationItem.rightBarButtonItem setTit原创 2017-02-23 15:29:19 · 8605 阅读 · 1 评论 -
IOS--CGFloat与Float的区别
CGFloat is just a typedef for either float or double.typedef float CGFloat;// 32-bittypedef double CGFloat;// 64-bit对于需要兼容64位机器的程序而言,需要用CGFloat,当然从长远角度考虑还是推荐尽量使用CGFloat。尽管在32位上相比float增加了一些memory foot原创 2017-02-22 15:19:59 · 3052 阅读 · 0 评论 -
UITextView 基本用法
self.textView=[[[UITextView alloc] initWithFrame:self.view.frame] autorelease]; //初始化大小并自动释放 self.textView.textColor = [UIColor blackColor];//设置textview里面的字体颜色 self.textView.font = [UIFont fontWithN原创 2017-02-22 13:59:38 · 432 阅读 · 0 评论 -
Swift3.0 设置UILabel文件行间距 含oc版
UILabel实用设置行间距代码,直接上代码 swift: fileprivate func createUI(){ let subLabel = UILabel() subLabel.font = UIFont(name: "EuphemiaUCAS", size: 19.0) subLabel.numberOfLines = 0原创 2016-12-26 15:32:47 · 4978 阅读 · 0 评论 -
修改系统UISearchBar搜索框的样式-搜索图片、背景颜色
修改系统搜索框 //searchbar //设置背景图是为了去掉上下黑线 self.searchBar.backgroundImage = [[UIImage alloc] init]; // 设置SearchBar的颜色主题为白色 self.searchBar.barTintColor = [UIColor whiteColor]; self.searchB原创 2016-12-15 14:21:53 · 6364 阅读 · 0 评论 -
UIButton设置UIControlContentHorizontalAlignment调整文字对齐方式
descripBtn.titleLabel.textAlignment = NSTextAlignmentLeft; //这行代码是没有效果的,这只是让标签中的文本左对齐,但并没有改变标签在按钮中的对齐方式UIButton 继承自UIControl,所以可以对UIControlContentHorizontalAlignment进行设置 typedef NS_ENUM(NSInteger,原创 2016-12-13 17:18:18 · 8283 阅读 · 1 评论 -
IOS手机号、 邮箱、 电话、 数字、 身份证、 银行卡 正则判断
//昵称(账号)+ (BOOL) validateNickname:(NSString *)nickname{// NSString *nicknameRegex = @"^[\u4e00-\u9fa5A-Za-z0-9]{4,16}$"; NSString *nicknameRegex = @"^[a-zA-Z0-9]{3,16}$"; NSPredicate *pass转载 2016-12-07 15:36:35 · 1466 阅读 · 0 评论 -
IOS根据屏幕尺寸判断是否为iphone6plus尺寸
根据屏幕尺寸判断各机型尺寸 #define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) #define __kScreenHeight ([[UIScreen mainScreen]bounds].size.height) #define __kScreenWidth ([[UISc原创 2016-11-28 15:55:58 · 5781 阅读 · 0 评论 -
iOS 根据value取到 Dictionary 对应的key值
快速遍历取出value 对应字典中的 key 值 NSString *brithdayStrDefult;//上页面传过来的生日值 NSDictionary * brithdayDic = @{@"0":@"60后",@"1":@"70后",@"2":@"80后",@"3":@"90后",@"4":@"00后"}; //遍历取值 if (brithdayStrDefult.lengt原创 2016-11-24 16:18:40 · 7826 阅读 · 0 评论