ios7--UIImageView
//
// ViewController.m
// 03-UIImageView的使用
// #import "ViewController.h" @interface ViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *image2; @end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad]; // 1.创建UIImageView对象
UIImageView *imageView = [[UIImageView alloc] init]; // 2. 设置尺寸
// imageView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
//imageView.frame = self.view.bounds;//同上 imageView.frame = CGRectMake(, , , );
NSLog(@"%f",self.view.bounds.origin.x);
NSLog(@"%f",self.view.bounds.origin.y);
NSLog(@"%f",self.view.bounds.size.height);
NSLog(@"%f",self.view.bounds.size.width); // 3. 设置背景颜色
imageView.backgroundColor = [UIColor redColor]; // 4. 设置背景图片
imageView.image = [UIImage imageNamed:@""];//1图片,png, _image2.image = [UIImage imageNamed:@""];
_image2.frame = CGRectMake(, , , );
_image2.contentMode = UIViewContentModeCenter;
_image2.backgroundColor = [UIColor redColor];
//[self.view addSubview:_image2]; // 5.设置图片的内容模式
imageView.contentMode = UIViewContentModeScaleAspectFill; // 6.加毛玻璃,图片上加一个UIToolBar // 6.1 创建UIToolBar对象
UIToolbar *toolBar = [[UIToolbar alloc] init];
// 6.2 设置toolBar的frame
toolBar.frame = imageView.bounds;
// 6.3 设置毛玻璃的样式
toolBar.barStyle = UIBarStyleBlack;
toolBar.alpha = 0.98;
// 6.4 加到imageView中
[imageView addSubview:toolBar]; // 加到控制器的view中
[self.view addSubview:imageView]; } - (void)test{
// 1.1 创建UIImageView对象
UIImageView *imageView = [[UIImageView alloc] init]; // 1.2 设置frame
imageView.frame = CGRectMake(, , , ); // 1.3 设置背景
// imageView.backgroundColor = [UIColor greenColor]; // 1.4 设置图片 (png不需要后缀)
imageView.image = [UIImage imageNamed:@""]; /** UIViewContentModeRedraw, // 重新绘制 (核心绘图) drawRact //带有Scale,标明图片有可能被拉伸或压缩
UIViewContentModeScaleToFill, // 完全的压缩或拉伸 // Aspect 比例,缩放是带有比例的
UIViewContentModeScaleAspectFit, // 宽高比不变 Fit 适应
UIViewContentModeScaleAspectFill, // 宽高比不变 Fill 填充 //不带有Scale,标明图片不可能被拉伸或压缩
UIViewContentModeCenter,
UIViewContentModeTop,
UIViewContentModeBottom,
UIViewContentModeLeft,
UIViewContentModeRight,
UIViewContentModeTopLeft,
UIViewContentModeTopRight,
UIViewContentModeBottomLeft,
UIViewContentModeBottomRight,
*/
// 1.5 设置图片的内容模式
imageView.contentMode = UIViewContentModeScaleAspectFill; // 2.0 加到控制器的view中
[self.view addSubview:imageView]; // 裁剪多余的部分
imageView.clipsToBounds = YES;
} @end
//
// ViewController.m
// 04-UIImageView的frame设置
// #import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad];
/* // 设置frame的方式
// 方式一
UIImageView *imageView = [[UIImageView alloc] init];
imageView.image = [UIImage imageNamed:@"1"]; // imageView.frame = CGRectMake(100, 100, 267, 400);
// imageView.frame = (CGRect){{100, 100},{267, 400}}; //位置尺寸
*/ // 方式二
/*
UIImageView *imageView = [[UIImageView alloc] init];
// 创建一个UIImage对象
UIImage *image = [UIImage imageNamed:@"1"];
// 设置frame
imageView.frame = CGRectMake(100, 10, image.size.width, image.size.height);
// 设置图片
imageView.image = image;
*/ // 方式三
/*
// 创建一个UIImage对象
UIImage *image = [UIImage imageNamed:@"1"];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(100, 10, image.size.width, image.size.height)];
imageView.image = image;
*/ // 方式四 // 创建一个UIimageview对象
// 注意: initWithImage 默认就有尺寸--->图片的尺寸
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@""]]; // 改变位置
// imageView.center = CGPointMake(200, 150); imageView.center = CGPointMake(self.view.frame.size.width * 0.5, self.view.frame.size.height * 0.5); [self.view addSubview:imageView];
} @end
ios7--UIImageView的更多相关文章
- iOS7上TableViewCell的button和UIImageView个别未显示的bug
要做这个cell,用xib将cell做成之后,在iPhone6.6Plus.5s上运行良好,但是在iOS7的5s和iPad上,黄色的小星星和下载按钮均没有显示. 甚为惊奇. 在网上百度之,发现了解决办 ...
- 自定义iOS7导航栏背景,标题和返回按钮文字颜色
在iOS7下,默认导航栏背景,颜色是这样的,接下来我们就进行自定义,如果你仅仅是更改一下背景和颜色,代码会很简单,不需要很复杂的自定义View来替代leftBarItem 更改导航栏的背景和文字Col ...
- iOS 读取相册二维码,兼容ios7(使用CIDetector 和 ZXingObjC)
ios从相册读取二维码,在ios8以上,苹果提供了自带的识别图片二维码的功能,这种方式效率最好,也是最推荐的,但是如果你的系统需要向下兼容ios7,就必须用其他方式. 这里我选择的是 ZXingObj ...
- iOS7初体验(3)——图像资源Images Assets
开始之前,首先回顾一下iOS7初体验(1)——第一个应用程序HelloWorld中的一张图,如下所示: 本文便分享一下Images.xcassets的体验~_~ 1. 打开此前使用过的HelloWor ...
- ios NSURLSession(iOS7后,取代NSURLConnection)使用说明及后台工作流程分析
NSURLSession是iOS7中新的网络接口,它与咱们熟悉的NSURLConnection是并列的.在程序在前台时,NSURLSession与NSURLConnection可以互为替代工作.注意, ...
- iOS7中如何去除UINavigationbar下边的那条黑线
做项目过程中遇到要去掉导航栏下面的一条黑线,从网上找到的一个方法 默认UINavigationbar样式 准备用于替换的背景 替换后的效果 if ([self.navigationController ...
- 【转】自定义iOS7导航栏背景,标题和返回按钮文字颜色 -- 不错不错!!
原文网址:http://blog.csdn.net/mad1989/article/details/41516743 在iOS7下,默认导航栏背景,颜色是这样的,接下来我们就进行自定义,如果你仅仅是更 ...
- 【转】 自定义iOS7导航栏背景,标题和返回按钮文字颜色
原文:http://blog.csdn.net/mad1989/article/details/41516743 UIBarButtonItem,navigationItem,backBarButto ...
- iOS7——图像资源Images Assets
iOS7初体验(3)——图像资源Images Assets 分类: iOS开发2013-06-18 16:02 17583人阅读 评论(2) 收藏 举报 ios7Images xcassets图像资源 ...
- ##DAY2 UILabel、UITextField、UIButton、UIImageView、UISlider
##DAY2 UILabel.UITextField.UIButton.UIImageView.UISlider #pragma mark ———————UILabel——————————— UILa ...
随机推荐
- Windows提高_2.2第二部分:用户区同步
第二部分:用户区同步 同步和互斥 同步:就是按照一定的顺序执行不同的线程 互斥:当一个线程访问某一资源的时候,其它线程不能同时访问 多线程产生的问题 #include <stdio.h> ...
- CAD得到ImageMark数据(com接口VB语言)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 3 ...
- java_IO_1
public class DirStudy { public static void main(String[] args) { File file = new File("F:/Eclip ...
- 16Log4J
Log4J Log4j是Apache的一个开放源代码项目,通过使用Log4j,我们可以控制日志信息输送的目的地是控制台.文件.GUI组件.甚至是套接口服务器.NT的事件记录器.UNIX Syslog守 ...
- 使用SELECT语句检索数据
使用SELECT语句检索数据select指令适用于SQL数据库SELECT 语句用于从数据库中选取数据.(指令不分大小写,选择的值除名字和一些有特殊意义的字符可不分大小写,from结束时一定要加;) ...
- Linux查看用户列表
cat /etc/passwd 可以查看所有用户的列表w 可以查看当前活跃的用户列表cat /etc/group 查看用户组 groups 查看当前登录用户的组内成员groups gliethttp ...
- circumferential averaged streamwise velocity in ParaView
Goal: get a averaged axial velocity in a circular loop (dashed line in the following figure) Steps: ...
- Tree(树的还原以及树的dfs遍历)
紫书:P155 uva 548 You are to determine the value of the leaf node in a given binary tree that is th ...
- 3.1.1 简单的 grep
grep 最简单的用法就是使用固定字符串: [many@avention Desktop]$ who many :0 2019- ...
- java使用JNA框架调用dll动态库
这两天了解了一下java调用dll动态库的方法,总的有三种:JNI.JNA.JNative.其中JNA调用DLL是最方便的. ·JNI ·JNA ·JNative java使用 JNI来调用dll动态 ...