美文网首页
访问系统相册的创建

访问系统相册的创建

作者: 围篱亦海庄 | 来源:发表于2016-07-12 22:07 被阅读0次

       使用OS的系统,在使用OC语言的基础上创建访问系统相册,就是创建其他应用程序的部分语句,也就是在苹果系统上QQ的登录系统的一部分。

#import"ViewController.h"

//遵守协议

@interfaceViewController()

@property(nonatomic,strong)UIButton*userBtu;

@end

@implementationViewController

- (void)viewDidLoad {

[superviewDidLoad];

//所有的能看得到的UI控件创建初始化方式都可以采用allocinitWithFrame

self.userBtu= [[UIButtonalloc]initWithFrame:CGRectMake(30,60,80,80)];

//设置颜色

self.userBtu.backgroundColor= [UIColorredColor];

//将图片加载到内存中

UIImage*image = [UIImageimageNamed:@"login_header"];

//将加到内存后的图片设置为背景图片

[self.userBtusetBackgroundImage:imageforState:(UIControlStateNormal)];

//设置圆形半径

self.userBtu.layer.cornerRadius=40;

//超过内切圆的图片给切割掉

self.userBtu.layer.masksToBounds=YES;

//添加点击事件:去访问系统相册

[self.userBtuaddTarget:selfaction:@selector(setUserImage)forControlEvents:(UIControlEventTouchUpInside)];

//将按钮添加到屏幕上面来

[self.viewaddSubview:self.userBtu];

}

//访问系统相册

-(void)setUserImage

{

UIImagePickerController*imagePicker = [[UIImagePickerControlleralloc]init];

//设置代理,到@interface后面

UIImagePickerControllerDelegate>

imagePicker.delegate=self;

//弹出相册

[selfpresentViewController:imagePickeranimated:YEScompletion:nil];

}

//这个方法是协议UIImagePickerControllerDelegate里面的,选择图片结束的时候就会自动调用

- (void)imagePickerController:(UIImagePickerController*)picker

didFinishPickingImage:(UIImage*)image editingInfo:(nullableNSDictionary *)editingInfo

{

//设置头像

[self.userBtusetBackgroundImage:imageforState:(UIControlStateNormal)];

//将系统相册消失掉

[pickerdismissViewControllerAnimated:YEScompletion:nil];

}

- (void)didReceiveMemoryWarning {

[superdidReceiveMemoryWarning];

// Dispose of any

resources that can be recreated.

}

@end

相关文章

  • 访问系统相册的创建

    使用OS的系统,在使用OC语言的基础上创建访问系统相册,就是创建其他应用程序的部分语句,也就是在苹果系统上Q...

  • 访问系统相册

    在iOS中要拍照和录制视频最简单的方式就是调用UIImagePickerController,UIImagePic...

  • 访问系统相册

    下午上了访问系统相册 圆形的头像半径是宽度的一半 注意设置代理,到@interface后面遵守协议 而且所有的能...

  • 访问系统相册

    //遵守协议 @interfaceViewController() @property(nonatomic,str...

  • 访问系统相册

    // ViewController.m // 访问系统相册 // // Created by lanouhn on...

  • 访问系统相册

    //遵守协议 @interface ViewController () @property(nonatomic,s...

  • 个人相册开发(9)

    一.类似个人相册界面的系统相册界面 1.创建系统相册的界面XLSystemAlbumController类,利用父...

  • 压缩图片和相册权限

    等比例压缩图片 弹出系统相册访问权限(允许或者不允许) 判断是否有访问相册的权限

  • oc语言的学习笔记整理:访问相册

    // // ViewController.m //访问系统相册 // // Created by lanou on...

  • OC语言学习习得

    / ViewController.m //访问系统相册 // // Created by lanou on 16/...

网友评论

      本文标题:访问系统相册的创建

      本文链接:https://www.haomeiwen.com/subject/nljsjttx.html