ios开发零散知识点总结
1:当有导航栏的时候,子视图为UIScrollView,或是继承于UIScrollView的控件如UITableView,UICollectionView等,控制器会自动调用
self.automaticallyAdjustsScrollViewInsets = YES;方法,自动为控件添加64的额外的滚动区域,若存在多个控件,则系统会自动找到第一个添加的控件,执行此方法,增加64额外的滚动区域,如果想禁止此操作,可在控制器中实现方法:self.automaticallyAdjustsScrollViewInsets = NO;或是设置UIScrollView的contentInset,tableView的contentInset,来减少滚动区域。
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// 1:不会自动去调整uiscrollView的contentInset属性
self.automaticallyAdjustsScrollViewInsets = NO;
UIScrollView *scrollView = [[UIScrollView alloc] init];
scrollView.frame = CGRectMake(, , , );
scrollView.backgroundColor = [UIColor redColor];
[self.view addSubview:scrollView];
[scrollView addSubview:[[UISwitch alloc] init]];
}
2:在宏定义文件中的NSLog定义
#ifdef DEBUG #define DLog(...) NSLog(__VA_ARGS__) #else #define DLog(...) #endif
一些颜色的宏定义
//1:RGB颜色
#define RGB(a,b,c) [UIColor colorWithRed:(a)/255.0 green:(b)/255.0 blue:(c)/255.0 alpha:1] //2:包含设置透明度
#define RGBColor(a,b,c,d) [UIColor colorWithRed:(a)/255.0 green:(b)/255.0 blue:(c)/255.0 alpha:d] //3:随机色
#define ARC4Color RGB(arc4random_uniform(256),arc4random_uniform(256),arc4random_uniform(256))
3:pch文件的定义:在项目的Target---BuildSetting---prefixHeader---删除在桌面文件夹的路径,只保留项目的路径,再输入$(SRCROOT),如:$(SRCROOT)/网易新闻抽屉效果/Classes/Main/Utils/PrefixHeader.pch
4:通过图形上下文将color绘制成一张图片:
//提供颜色接口,返回一张图片 #import <UIKit/UIKit.h> @interface UIImage (Cqb) +(UIImage*)imageWithColor:(UIColor*)color;
@end
#import "UIImage+Cqb.h"
@implementation UIImage (Cqb)
+ (UIImage*)imageWithColor:(UIColor*)color {
//1:开启基于位图的图形上下文
CGFloat imageWidth = ;
CGFloat imageHeight = ;
UIGraphicsBeginImageContextWithOptions(CGSizeMake(imageWidth, imageHeight), NO, 0.0);
//2:画一个color颜色的矩形框
[color set];
UIRectFill(CGRectMake(, , imageWidth, imageHeight));
//3:得到图片
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
//4:关闭图形上下文
UIGraphicsEndImageContext();
return image;
}
5:UIView计算尺寸的分类:
#import <UIKit/UIKit.h> @interface UIView (Cqb)
@property (nonatomic,assign)CGFloat X;
@property (nonatomic,assign)CGFloat Y;
@property (nonatomic,assign)CGFloat width;
@property (nonatomic,assign)CGFloat height;
@property (nonatomic,assign)CGFloat centerX;
@property (nonatomic,assign)CGFloat centerY;
@property (nonatomic,assign)CGSize size;
@end
#import "UIView+Cqb.h"
@implementation UIView (Cqb)
- (void)setX:(CGFloat)X {
CGRect frame = self.frame;
frame.origin.x = X;
self.frame = frame;
}
- (CGFloat)X {
return self.frame.origin.x;
}
- (void)setY:(CGFloat)Y {
CGRect frame = self.frame;
frame.origin.y = Y;
self.frame = frame;
}
- (CGFloat)Y {
return self.frame.origin.y;
}
- (void)setWidth:(CGFloat)width {
CGRect frame = self.frame;
frame.size.width = width;
self.frame = frame;
}
- (CGFloat)width {
return self.frame.size.width;
}
- (void)setHeight:(CGFloat)height {
CGRect frame = self.frame;
frame.size.height = height;
self.frame = frame;
}
- (CGFloat)height {
return self.frame.size.height;
}
- (void)setCenterX:(CGFloat)centerX {
CGPoint center = self.center;
center.x = centerX;
self.center = center;
}
- (CGFloat)centerX {
return self.center.x;
}
- (void)setCenterY:(CGFloat)centerY {
CGPoint center = self.center;
center.y = centerY;
self.center = center;
}
- (CGFloat)centerY {
return self.center.y;
}
- (void)setSize:(CGSize)size {
CGRect frame = self.frame;
frame.size = size;
self.frame = frame;
}
- (CGSize)size {
return self.frame.size;
}
@end
6:对自定义UIBarButtonItem的分类封装:
#import <UIKit/UIKit.h> @interface UIBarButtonItem (Extension)
+ (UIBarButtonItem *)itemWithImageName:(NSString *)imageName target:(id)target action:(SEL)action;
@end
#import "UIBarButtonItem+Extension.h" @implementation UIBarButtonItem (Extension)
+ (UIBarButtonItem *)itemWithImageName:(NSString *)imageName target:(id)target action:(SEL)action
{
UIButton *button = [[UIButton alloc] init];
[button setBackgroundImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal]; // 设置按钮的尺寸为背景图片的尺寸
button.size = button.currentBackgroundImage.size; // 监听按钮点击
[button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
return [[UIBarButtonItem alloc] initWithCustomView:button];
}
@end
6:当做真机调试的时候,要在buildSetting中配置好证书,并在info里选择开发者账号才可以
ios开发零散知识点总结的更多相关文章
- iOS学习——iOS开发小知识点集合
在iOS学习和开发过程中,经常会遇到一些很小的知识点和问题,一两句话就可以解释清楚了,这样的知识点写一篇随笔又没有必要,但是又想mark一下,以备不时之需,所以就有了本文.后面遇到一些小的知识点会不断 ...
- IOS开发,知识点小结,ios开发中经常使用的宏定义总结
IOS开发,从应用跳转到用浏览器打开网页: [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http:// ...
- iOS开发零碎知识点
记录一些常用和不常用的iOS知识点,防止遗忘丢失.(来源为收集自己项目中用到的或者整理看到博客中的知识点),如有错误,欢迎大家批评指正:如有好的知识点,也欢迎大家联系我,添加上去.谢谢! 一.调用代码 ...
- iOS开发 小知识点
1/ iOS汉字百分号互相转换. //汉字 NSString * name = @"时间终于将我对你的爱消耗殆尽"; //汉字转为百分比 NSString * encodeStri ...
- iOS开发系列--IOS程序开发概览
概览 终于到了真正接触IOS应用程序的时刻了,之前我们花了很多时间去讨论C语言.ObjC等知识,对于很多朋友而言开发IOS第一天就想直接看到成果,看到可以运行的IOS程序.但是这里我想强调一下,前面的 ...
- IOS开发涉及有点概念&相关知识点
前言,IOS是基于UNIX的,用C/C+/OC直通系统底层,不想android有个jvm. 首先还是系统架构的分层架构 1.核心操作系统层 Core OS,就是内存管理.文件系统.电源管理等 2.核心 ...
- iOS开发中关于UIImage的知识点总结
UIImage是iOS中层级比较高的一个用来加载和绘制图像的一个类,更底层的类还有 CGImage,以及iOS5.0以后新增加的CIImage.今天我们主要聊一聊UIImage的三个属性: image ...
- iOS开发:开发证书知识点总结
1. Error: An App ID with identifier "*" is not avaliable. Please enter a different string. ...
- iOS开发核心语言Objective C —— 所有知识点总结
C和OC对比 OC中主要开发在什么平台上的应用程序?答:可以使用OC开发Mac OS X平台和iOS平台的应用程序 OC中新增关键字大部分是以什么开头?答:OC中新增关键字大部分是以@开头 OC中新增 ...
随机推荐
- Chrome不能在网易网盘中上传文件的解决办法
Chrome不能在网易网盘中上传文件的解决办法1. 安装 Adobe Flash Player PPAPI,设置flash插件 chrome://settings/content/flash,许可[* ...
- 对 hiren bootcd 15.2 中的 XP 系统作了汉化, 同时支持中文输入法。提供下载
对 hiren bootcd 15.2 中的 XP 系统作了汉化, 同时支持中文输入法.提供下载 对该PE 中的 XP 系统作了汉化, 由于一个 中文字库 就要 10M 多:加之原系统过于精简,对中文 ...
- searchView-风格调整
5.1以后的searchView 风格调整属性相比于4.4有了些更改.我们先看代码 <style name="DeskClock.Theme" parent="an ...
- NOIP2015运输计划(二分答案)
题目描述 公元2044年,人类进入了宇宙纪元. L国有n个星球,还有n-1条双向航道,每条航道建立在两个星球之间,这n-1条航道连通了L国的所有星球. 小P掌管一家物流公司,该公司有很多个运输计划,每 ...
- 使用PyCharm安装第三方库
使用PyCharm安装第三方库是一种十分简单的做法,接下来我来演示一下在PyCharm上安装第三方库requess的操作流程. 首先,先看一下当第三方库未安装时的提示内容,在pycharm中新建pyt ...
- Dialog和FormView如何派生通用类
派生通用类涉及到派生类的构造函数需要传递窗口ID和CWnd,所以要在派生类中事先定义好 在Dialog中构造函数是这样定义的 public: CDialogEx(); CDialogEx(UINT n ...
- 使用 Go 语言开发大型 MMORPG 游戏服务器怎么样?(非常稳定、捕获所有异常、非常适合从头开始,但大公司已经有现成的C++框架、所以不会使用)
使用 Go 语言开发大型 MMORPG 游戏服务器怎么样?和C Socket服务器比起来有什么优劣?可行性怎么样? 从2013年起,经朋友推荐开始用Golang编写游戏登陆服务器, 配合C++做第三方 ...
- code-代码平台服务器路径
下面记录的是各个平台的服务器路径(va使用) ("repo init -u ssh://vanzo/platform_89/manifest.git") ("repo i ...
- 15.lambda表达式
#include <iostream> #include <array> using namespace std; //解决函数怀孕现象 //[](){} //[] =引用,只 ...
- 【前端图表】echarts实现散点图x轴时间轴
话不多说,老规矩,先上图,实现echarts实现散点图,x轴数据为时间年月日. 实现代码如下: <!DOCTYPE html> <html> <head> < ...