184使用 Core Image 框架处理照片

实现图片的老旧、色彩、旋转效果
(1)使用 StoryBoard 故事版布局界面;

(2)使用 Core Image 框架的 CIFilter 过滤器;分别对应的过滤器名称是:CISepiaTone(棕黑色调)、CIHueAdjust(色彩调整)、CIStraightenFilter(纠正过滤器);

(3)另外就是使用 UIImagePickerController 来从图片库中选择图片,使用 ALAssetsLibrary 保存过滤器效果处理后的图片到图片库里。

图片处理过程:
1、创建基于 GPU的CIContext 对象实例
2、通过过滤器名称创建 CIFilter 对象实例
3、设置 CIFilter 对象实例参数
4、通过 CIFilter 对象实例的 outputImage 方法产生 CIImager 对象实例
5、通过 CIContext 对象实例的 createCGImage 方法将 CIImager 对象实例转换为 CGImageRef 对象实例
6、通过 UIImage 类的 imageWithCGImage 方法创建 UIImage 对象实例
7、绑定图片视图的图片为过滤器效果处理后的 UIImage 对象实例
8、使用 CGImageRelease 方法释放 CGImageRef 对象实例

关键操作:

效果如下:

iPhone 5s

iPhone 6

iPhone 6 Plus

ViewController.h

 1 #import <UIKit/UIKit.h>
 2 #import <AssetsLibrary/AssetsLibrary.h>
 3
 4 @interface ViewController : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate>
 5 @property (strong, nonatomic) IBOutlet UIImageView *imgVCustom;
 6 @property (strong, nonatomic) IBOutlet UISlider *sldSepiaTone;
 7 @property (strong, nonatomic) IBOutlet UISlider *sldHueAdjust;
 8 @property (strong, nonatomic) IBOutlet UISlider *sldStraightenFilter;
 9
10 @end

ViewController.m

  1 #import "ViewController.h"
  2
  3 @interface ViewController ()
  4 @property (strong, nonatomic) CIContext *context;
  5 @property (strong, nonatomic) CIImage *imgSource;
  6 @property (strong, nonatomic) CIFilter *filterSepiaTone;
  7 @property (strong, nonatomic) CIFilter *filterHueAdjust;
  8 @property (strong, nonatomic) CIFilter *filterStraightenFilter;
  9 - (void)layoutUI;
 10 - (void)displayImageWithFilter:(CIFilter *)filter;
 11 @end
 12
 13 @implementation ViewController
 14
 15 - (void)viewDidLoad {
 16     [super viewDidLoad];
 17
 18     [self layoutUI];
 19 }
 20
 21 - (void)didReceiveMemoryWarning {
 22     [super didReceiveMemoryWarning];
 23     // Dispose of any resources that can be recreated.
 24 }
 25
 26 - (void)layoutUI {
 27     //设置是否是连续性的;默认值为YES,表示拉动中也会触发Value Changed事件方法;这里我们设置为NO,在拉动后才触发
 28     _sldSepiaTone.continuous = NO;
 29     _sldHueAdjust.continuous = NO;
 30     _sldStraightenFilter.continuous = NO;
 31
 32     //得到图片路径创建CIImage对象实例
 33     NSString *filePath = [[NSBundle mainBundle] pathForResource:@"Big-Buck-Bunny-Clip" ofType:@"png"];
 34     NSURL *fileURL = [NSURL fileURLWithPath:filePath];
 35     _imgSource = [CIImage imageWithContentsOfURL:fileURL];
 36
 37     //创建基于CPU的CIContext对象实例
 38     //_context = [CIContext contextWithOptions: [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:kCIContextUseSoftwareRenderer]];
 39
 40     //创建基于GPU的CIContext对象实例
 41     _context = [CIContext contextWithOptions: nil];
 42
 43     //创建过滤器
 44     _filterSepiaTone = [CIFilter filterWithName:@"CISepiaTone"]; //棕黑色调
 45     _filterHueAdjust = [CIFilter filterWithName:@"CIHueAdjust"]; //色彩调整
 46     _filterStraightenFilter = [CIFilter filterWithName:@"CIStraightenFilter"]; //纠正过滤器
 47 }
 48
 49 - (void)displayImageWithFilter:(CIFilter *)filter {
 50     //得到过滤后的图片
 51     CIImage *imgOutput = [filter outputImage];
 52
 53     //转换图片
 54     CGImageRef imgRef = [_context createCGImage:imgOutput fromRect:[imgOutput extent]];
 55     UIImage *imgNew = [UIImage imageWithCGImage:imgRef];
 56
 57     _imgVCustom.image = imgNew;
 58
 59     //释放CGImageRef对象实例
 60     CGImageRelease(imgRef);
 61 }
 62
 63 #pragma mark - IBAction
 64 - (IBAction)changeSepiaTone:(id)sender {
 65     _sldHueAdjust.value = 0.0;
 66     _sldStraightenFilter.value = 0.0;
 67     float slideVal = _sldSepiaTone.value;
 68
 69     //设置过滤器参数
 70     [_filterSepiaTone setValue:_imgSource forKey:kCIInputImageKey];
 71     [_filterSepiaTone setValue:[NSNumber numberWithFloat:slideVal] forKey:@"inputIntensity"];
 72
 73     [self displayImageWithFilter:_filterSepiaTone];
 74 }
 75
 76 - (IBAction)changeHueAdjust:(id)sender {
 77     _sldSepiaTone.value = 0.0;
 78     _sldStraightenFilter.value = 0.0;
 79     float slideVal = _sldHueAdjust.value;
 80
 81     //设置过滤器参数
 82     [_filterHueAdjust setValue:_imgSource forKey:kCIInputImageKey];
 83     [_filterHueAdjust setValue:[NSNumber numberWithFloat:slideVal] forKey:@"inputAngle"];
 84
 85     [self displayImageWithFilter:_filterHueAdjust];
 86 }
 87
 88 - (IBAction)changeStraightenFilter:(id)sender {
 89     _sldSepiaTone.value = 0.0;
 90     _sldHueAdjust.value = 0.0;
 91     float slideVal = _sldStraightenFilter.value;
 92
 93     //设置过滤器参数
 94     [_filterStraightenFilter setValue:_imgSource forKey:kCIInputImageKey];
 95     [_filterStraightenFilter setValue:[NSNumber numberWithFloat:slideVal] forKey:@"inputAngle"];
 96
 97     [self displayImageWithFilter:_filterStraightenFilter];
 98 }
 99
100 - (IBAction)resetImage:(id)sender {
101     //得到图片路径创建CIImage对象实例
102     NSString *filePath = [[NSBundle mainBundle] pathForResource:@"Big-Buck-Bunny-Clip" ofType:@"png"];
103     NSURL *fileURL = [NSURL fileURLWithPath:filePath];
104     _imgSource = [CIImage imageWithContentsOfURL:fileURL];
105
106     //重置滑杆值
107     _sldSepiaTone.value = 0.0;
108     _sldHueAdjust.value = 0.0;
109     _sldStraightenFilter.value = 0.0;
110     _imgVCustom.image = [UIImage imageWithContentsOfFile:filePath];
111 }
112
113 - (IBAction)chooseImage:(id)sender {
114     UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
115     imagePickerController.delegate = self;
116     [self presentViewController:imagePickerController
117                        animated:YES
118                      completion:^{
119                          //code
120                      }];
121 }
122
123 - (IBAction)saveImage:(id)sender {
124     CIFilter *filter;
125     if (_sldSepiaTone.value != 0.0) {
126         filter = _filterSepiaTone;
127     } else if (_sldHueAdjust.value != 0.0) {
128         filter = _filterHueAdjust;
129     } else {
130         filter = _filterStraightenFilter;
131     }
132
133     CIImage *imgOutput = [filter outputImage];
134     CGImageRef imgRefToSave = [_context createCGImage:imgOutput fromRect:[imgOutput extent]];
135
136     //需要导入头文件<AssetsLibrary/AssetsLibrary.h>
137     //保存到图片库中
138     ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
139     [library writeImageToSavedPhotosAlbum:imgRefToSave
140                                  metadata:[imgOutput properties]
141                           completionBlock:^(NSURL *assetURL, NSError *error) {
142                               CGImageRelease(imgRefToSave);
143
144                               UIAlertView *alertV = [[UIAlertView alloc] initWithTitle:@"提示信息"
145                                                                                message:@"保存成功"
146                                                                               delegate:nil
147                                                                      cancelButtonTitle:nil
148                                                                      otherButtonTitles:@"确定", nil];
149                               [alertV show];
150                           }];
151 }
152
153 #pragma mark - UIImagePickerControllerDelegate
154 - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
155     [self dismissViewControllerAnimated:YES completion:nil];
156
157     UIImage *imgChoice = [info objectForKey:UIImagePickerControllerOriginalImage];
158     _imgSource = [CIImage imageWithCGImage:imgChoice.CGImage];
159     _imgVCustom.image = imgChoice;
160 }
161
162 - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
163     [self dismissViewControllerAnimated:YES completion:nil];
164 }
165
166 @end

Main.storyboard

  1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2 <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7702" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="vXZ-lx-hvc">
  3     <dependencies>
  4         <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7701"/>
  5     </dependencies>
  6     <scenes>
  7         <!--View Controller-->
  8         <scene sceneID="ufC-wZ-h7g">
  9             <objects>
 10                 <viewController id="vXZ-lx-hvc" customClass="ViewController" sceneMemberID="viewController">
 11                     <layoutGuides>
 12                         <viewControllerLayoutGuide type="top" id="jyV-Pf-zRb"/>
 13                         <viewControllerLayoutGuide type="bottom" id="2fi-mo-0CV"/>
 14                     </layoutGuides>
 15                     <view key="view" contentMode="scaleToFill" id="kh9-bI-dsS">
 16                         <rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
 17                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
 18                         <subviews>
 19                             <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="Big-Buck-Bunny-Clip.png" translatesAutoresizingMaskIntoConstraints="NO" id="ReO-qZ-fAW">
 20                                 <rect key="frame" x="140" y="40" width="320" height="320"/>
 21                                 <constraints>
 22                                     <constraint firstAttribute="width" constant="320" id="C2r-Kz-KPF"/>
 23                                     <constraint firstAttribute="height" constant="320" id="dkB-gF-zbC"/>
 24                                 </constraints>
 25                             </imageView>
 26                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="老旧" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="OWZ-rg-m0K">
 27                                 <rect key="frame" x="160" y="386" width="34" height="21"/>
 28                                 <fontDescription key="fontDescription" type="system" pointSize="17"/>
 29                                 <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
 30                                 <nil key="highlightedColor"/>
 31                             </label>
 32                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="色彩" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="k3P-wv-puF">
 33                                 <rect key="frame" x="160" y="432" width="34" height="21"/>
 34                                 <fontDescription key="fontDescription" type="system" pointSize="17"/>
 35                                 <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
 36                                 <nil key="highlightedColor"/>
 37                             </label>
 38                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="旋转" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="uSa-M2-dak">
 39                                 <rect key="frame" x="160" y="477" width="34" height="21"/>
 40                                 <fontDescription key="fontDescription" type="system" pointSize="17"/>
 41                                 <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
 42                                 <nil key="highlightedColor"/>
 43                             </label>
 44                             <slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" minValue="0.0" maxValue="1" translatesAutoresizingMaskIntoConstraints="NO" id="za9-U7-UTZ">
 45                                 <rect key="frame" x="222" y="382" width="200" height="31"/>
 46                                 <constraints>
 47                                     <constraint firstAttribute="width" constant="196" id="5L7-au-P38"/>
 48                                     <constraint firstAttribute="height" constant="30" id="LTM-RW-tBZ"/>
 49                                 </constraints>
 50                                 <connections>
 51                                     <action selector="changeSepiaTone:" destination="vXZ-lx-hvc" eventType="valueChanged" id="s3f-rF-RWp"/>
 52                                 </connections>
 53                             </slider>
 54                             <slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" minValue="-3.1400000000000001" maxValue="3.1400000000000001" translatesAutoresizingMaskIntoConstraints="NO" id="D5r-XT-NhQ">
 55                                 <rect key="frame" x="222" y="428" width="200" height="31"/>
 56                                 <constraints>
 57                                     <constraint firstAttribute="width" constant="196" id="E9q-ag-z5a"/>
 58                                     <constraint firstAttribute="height" constant="30" id="rfR-PP-ZFJ"/>
 59                                 </constraints>
 60                                 <connections>
 61                                     <action selector="changeHueAdjust:" destination="vXZ-lx-hvc" eventType="valueChanged" id="8mV-I5-bQo"/>
 62                                 </connections>
 63                             </slider>
 64                             <slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" minValue="-3.1400000000000001" maxValue="3.1400000000000001" translatesAutoresizingMaskIntoConstraints="NO" id="SJf-EV-oYp">
 65                                 <rect key="frame" x="222" y="473" width="200" height="31"/>
 66                                 <constraints>
 67                                     <constraint firstAttribute="height" constant="30" id="MDv-9v-eTp"/>
 68                                     <constraint firstAttribute="width" constant="196" id="QPl-IW-Cr1"/>
 69                                 </constraints>
 70                                 <connections>
 71                                     <action selector="changeStraightenFilter:" destination="vXZ-lx-hvc" eventType="valueChanged" id="SQH-LR-ujT"/>
 72                                 </connections>
 73                             </slider>
 74                             <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="0Te-5X-NMj">
 75                                 <rect key="frame" x="162" y="522" width="30" height="30"/>
 76                                 <state key="normal" title="重置">
 77                                     <color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
 78                                 </state>
 79                                 <connections>
 80                                     <action selector="resetImage:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="LA0-CK-Cax"/>
 81                                 </connections>
 82                             </button>
 83                             <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="6cL-cO-scq">
 84                                 <rect key="frame" x="408" y="522" width="30" height="30"/>
 85                                 <state key="normal" title="保存">
 86                                     <color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
 87                                 </state>
 88                                 <connections>
 89                                     <action selector="saveImage:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="CeK-jp-JjI"/>
 90                                 </connections>
 91                             </button>
 92                             <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="RJd-TD-yLu">
 93                                 <rect key="frame" x="285" y="522" width="30" height="30"/>
 94                                 <state key="normal" title="照片">
 95                                     <color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
 96                                 </state>
 97                                 <connections>
 98                                     <action selector="chooseImage:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="ZaP-zL-bjr"/>
 99                                 </connections>
100                             </button>
101                         </subviews>
102                         <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
103                         <constraints>
104                             <constraint firstItem="RJd-TD-yLu" firstAttribute="leading" secondItem="ReO-qZ-fAW" secondAttribute="leading" constant="111" id="1Xc-pv-nf5"/>
105                             <constraint firstItem="ReO-qZ-fAW" firstAttribute="trailing" secondItem="6cL-cO-scq" secondAttribute="trailing" constant="22" id="2eD-1z-x0R"/>
106                             <constraint firstItem="za9-U7-UTZ" firstAttribute="leading" secondItem="ReO-qZ-fAW" secondAttribute="leading" constant="84" id="3NB-Bx-Q6O"/>
107                             <constraint firstItem="SJf-EV-oYp" firstAttribute="leading" secondItem="ReO-qZ-fAW" secondAttribute="leading" constant="84" id="83Z-cU-kxw"/>
108                             <constraint firstItem="RJd-TD-yLu" firstAttribute="top" secondItem="ReO-qZ-fAW" secondAttribute="bottom" constant="162" id="9gi-rx-JP8"/>
109                             <constraint firstItem="za9-U7-UTZ" firstAttribute="top" secondItem="ReO-qZ-fAW" secondAttribute="bottom" constant="22" id="Cvd-N5-JI2"/>
110                             <constraint firstItem="RJd-TD-yLu" firstAttribute="centerX" secondItem="ReO-qZ-fAW" secondAttribute="centerX" id="D1Y-sj-sEJ"/>
111                             <constraint firstItem="uSa-M2-dak" firstAttribute="top" secondItem="ReO-qZ-fAW" secondAttribute="bottom" constant="117" id="E87-nx-szc"/>
112                             <constraint firstItem="ReO-qZ-fAW" firstAttribute="leading" secondItem="D5r-XT-NhQ" secondAttribute="leading" constant="-84" id="X5f-S0-s32"/>
113                             <constraint firstItem="ReO-qZ-fAW" firstAttribute="leading" secondItem="6cL-cO-scq" secondAttribute="leading" constant="-202" id="YDf-6o-ael"/>
114                             <constraint firstItem="k3P-wv-puF" firstAttribute="top" secondItem="ReO-qZ-fAW" secondAttribute="bottom" constant="72" id="aR4-nO-nDR"/>
115                             <constraint firstItem="SJf-EV-oYp" firstAttribute="top" secondItem="ReO-qZ-fAW" secondAttribute="bottom" constant="113" id="b4C-YG-pCD"/>
116                             <constraint firstItem="ReO-qZ-fAW" firstAttribute="top" secondItem="jyV-Pf-zRb" secondAttribute="bottom" constant="20" id="bDR-wl-gln"/>
117                             <constraint firstItem="OWZ-rg-m0K" firstAttribute="leading" secondItem="ReO-qZ-fAW" secondAttribute="leading" constant="20" id="eSk-OG-mwG"/>
118                             <constraint firstItem="6cL-cO-scq" firstAttribute="top" secondItem="ReO-qZ-fAW" secondAttribute="bottom" constant="162" id="fDO-my-Y2B"/>
119                             <constraint firstItem="0Te-5X-NMj" firstAttribute="leading" secondItem="ReO-qZ-fAW" secondAttribute="leading" constant="22" id="gnL-Tl-Gct"/>
120                             <constraint firstItem="k3P-wv-puF" firstAttribute="leading" secondItem="ReO-qZ-fAW" secondAttribute="leading" constant="20" id="iLD-r8-ys0"/>
121                             <constraint firstItem="OWZ-rg-m0K" firstAttribute="top" secondItem="ReO-qZ-fAW" secondAttribute="bottom" constant="26" id="l0h-GI-Jl5"/>
122                             <constraint firstItem="uSa-M2-dak" firstAttribute="leading" secondItem="ReO-qZ-fAW" secondAttribute="leading" constant="20" id="loZ-MY-9xZ"/>
123                             <constraint firstItem="D5r-XT-NhQ" firstAttribute="top" secondItem="ReO-qZ-fAW" secondAttribute="bottom" constant="68" id="ltH-7b-Knn"/>
124                             <constraint firstItem="RJd-TD-yLu" firstAttribute="leading" secondItem="ReO-qZ-fAW" secondAttribute="leading" constant="111" id="nPl-Q1-9VA"/>
125                             <constraint firstItem="0Te-5X-NMj" firstAttribute="top" secondItem="ReO-qZ-fAW" secondAttribute="bottom" constant="162" id="s8u-rt-ZdR"/>
126                             <constraint firstItem="ReO-qZ-fAW" firstAttribute="centerX" secondItem="kh9-bI-dsS" secondAttribute="centerX" id="t69-2F-C2v"/>
127                         </constraints>
128                         <variation key="default">
129                             <mask key="constraints">
130                                 <exclude reference="YDf-6o-ael"/>
131                                 <exclude reference="1Xc-pv-nf5"/>
132                                 <exclude reference="nPl-Q1-9VA"/>
133                             </mask>
134                         </variation>
135                     </view>
136                     <connections>
137                         <outlet property="imgVCustom" destination="ReO-qZ-fAW" id="24S-lL-ecd"/>
138                         <outlet property="sldHueAdjust" destination="D5r-XT-NhQ" id="AcU-Md-asg"/>
139                         <outlet property="sldSepiaTone" destination="za9-U7-UTZ" id="IJb-Zv-KEu"/>
140                         <outlet property="sldStraightenFilter" destination="SJf-EV-oYp" id="fvE-8k-f0f"/>
141                     </connections>
142                 </viewController>
143                 <placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
144             </objects>
145         </scene>
146     </scenes>
147     <resources>
148         <image name="Big-Buck-Bunny-Clip.png" width="320" height="230"/>
149     </resources>
150 </document>
时间: 2024-12-06 02:18:39

184使用 Core Image 框架处理照片的相关文章

《从零開始学Swift》学习笔记(Day60)——Core Foundation框架

创文章,欢迎转载.转载请注明:关东升的博客   Core Foundation框架是苹果公司提供一套概念来源于Foundation框架,编程接口面向C语言风格的API.尽管在Swift中调用这样的C语言风格的API比較麻烦,可是在OS X和iOS开发过程中,有时候使用CoreFoundation框架的API是很方便的,比如在与C语言混合编码的时候. Core Foundation框架与Foundation框架紧密相关,他们具有与同样的接口,可是不同.Core Foundation框架是基于C语言

《从零开始学Swift》学习笔记(Day 61)——Core Foundation框架之内存管理

原创文章,欢迎转载.转载请注明:关东升的博客 在Swift原生数据类型.Foundation框架数据类型和Core Foundation框架数据类型之间转换过程中,虽然是大部分是可以零开销桥接,零开销并不意味着内存什么都不用管.Swift类型内存管理是采用ARC,Foundation类型和Core Foundation类型内存管理都是采用MRC或ARC,CoreFoundation类型内存管理是基于C语言风格的,它有一个对象所有权的概念. Objective-C的MRC内存管理 Core Fou

【转】Core Bluetooth框架之一:Central与Peripheral

原文网址:http://southpeak.github.io/blog/2014/07/29/core-bluetoothkuang-jia-zhi-%5B%3F%5D-:centralyu-peripheral/ iOS和Mac应用使用Core Bluetooth framework来与BLE(低功耗蓝牙)设备通信.我们的程序可以发现.搜索并与低功耗外围(Peripheral)蓝牙设备通信,如心跳监听器.数字温控器.甚至是其它iOS设备.这个框架抽象了支持蓝牙4.0标准低功耗设备的基本操作,

【转】Core Bluetooth框架之二:后台处理

原文网址:http://southpeak.github.io/blog/2014/07/31/core-bluetoothkuang-jia-zhi-er-:hou-tai-chu-li/ 在开发BLE相关应用时,由于应用在后台时会有诸多资源限制,需要考虑应用的后台处理问题.默认情况下,当程序位于后台或挂起时,大多数普通的Core Bluetooth任务都无法使用,不管是Central端还是Peripheral端.但我们可以声明我们的应用支持Core Bluetooth后台执行模式,以允许程序

Core Foundation 框架

Core Foundation 框架 2013-12-08 22:52 1978人阅读 评论(0) 收藏 举报 目录(?)[+] 转载自:http://blog.csdn.net/weiwangchao_/article/details/7744972 Core Foundation框架 (CoreFoundation.framework) 是一组C语言接口,它们为iOS应用程序提供基本数据管理和服务功能.下面列举该框架支持进行管理的数据以及可提供的服务: 群体数据类型 (数组.集合等) 程序包

Swift—Core Foundation框架-备

Core Foundation框架是苹果公司提供一套概念来源于Foundation框架,编程接口面向C语言风格的API.虽然在Swift中调用这种C语言风格的API比较麻烦,但是在OS X和iOS开发过程中,有时候使用CoreFoundation框架的API是非常方便的,例如在与C语言混合编码的时候. Core Foundation框架与Foundation框架紧密相关,他们具有与相同的接口,但是不同.Core Foundation框架是基于C语言风格的,而Foundation框架是基于Obje

在drawRect:方法中绘制图片,文字以及Core Graphics 框架的了解

p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000 } p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; min-height: 13.0px } p.p3 { margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #008400 }

IOS之Core Foundation框架和Cocoa Foundation框架的区别

Core Foundation框架 (CoreFoundation.framework) 是一组C语言接口,它们为iOS应用程序提供基本数据管理和服务功能.下面列举该框架支持进行管理的数据以及可提供的服务: 群体数据类型 (数组.集合等) 程序包 字符串管理 日期和时间管理 原始数据块管理 偏好管理 URL及数据流操作 线程和RunLoop 端口和soket通讯 Core Foundation框架和Foundation框架紧密相关,它们为相同功能提供接口,但Foundation框架提供Objec

ASP.NET Core 入门教程 2、使用ASP.NET Core MVC框架构建Web应用

原文:ASP.NET Core 入门教程 2.使用ASP.NET Core MVC框架构建Web应用 一.前言 1.本文主要内容 使用dotnet cli创建基于解决方案(sln+csproj)的项目 使用Visual Studio Code开发基于解决方案(sln+csproj)的项目 Visual Studio Code Solution插件( vscode-solution-explorer)基础使用介绍 基于 .NET Core web项目模板构建 ASP.NET Core MVC We