码迷,mamicode.com
首页 > 其他好文 > 详细

UILabel和UIImageView的使用

时间:2015-07-05 09:41:32      阅读:126      评论:0      收藏:0      [点我收藏+]

标签:uilabel   uiimageview   显示   对齐   

UILabel的使用

主要功能:显示文本用于内容提示

常用属性

NSString         *text; //UILabel显示的文本内容;

UIColor          *textColor; //文本显示的颜色

CGSize           *shadowColor; //文本显示的阴影

NSTextAlignment   textAlignment;//文本对齐方式(左对齐,居中,右对齐)

UIColor          *highlightedtextColor;//文本高亮是的显示颜色

BOOL             highlighted; //设置文本高亮

NSLineBreakMode  lineBreakMode; //如果需要多行显示需要设置这个属性

BOOL             userInteractionEnabled; //UILabel是否允许交互

NSInteger        numberOfLines;// UILabel文本显示的行数,如果是0表示不限制

BOOL             adjustsFontSizeToFitWidth;//根据UILabel大小调整字体大小

UIImageView 的使用

主要功能:在应用程序中主要用于显示图片的视图

常用属性

UIImage          *image;
//UIImageView显示的图片内容,默认是nil

UIImage          *highlightedImage;
//当UIImageView被选中的时候显示的图片内容 默认是nil

BOOL             userInteractionEnabled;
//UIImageView及其上得元素是否交互(非常重要)

BOOL             highlighted;//UIImageView是否是高亮状态

初始化方法

- (id)initWithImage:(UIImage*)image;
- (id)initWithImage:(UIImage*)image highlightedImage:(UIImage*)highlightedImage;

制作动画播放效果

#import "ViewController.h"

@interface ViewController ()

@property(strong,nonatomic) UIImageView *imageView;

@end

@implementation ViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    //定义一个存放图片对象的数组
    NSArray *imagesArray = [[NSArray alloc] initWithObjects:
                            [UIImage imageNamed:@"xiaohai.jpg"],
                            [UIImage imageNamed:@"xiaogou.jpg"],
                            [UIImage imageNamed:@"songshu.jpg"],
                            nil];
     //初始化一个图片视图
    _imageView = [[UIImageView alloc] initWithFrame:
    CGRectMake(100, 150, 150, 180)];

    //将图片数组赋值给图片视图的动画图片
    _imageView.animationImages = imagesArray;

    //设置图片按照原始比例缩放。保持纵横比
    _imageView.contentMode = UIViewContentModeScaleAspectFit;

    //切换动作的持续时间,秒
    _imageView.animationDuration = 2;

    //动画的重复次数,0时自由循环
    _imageView.animationRepeatCount = 0;

    [self.view addSubview:_imageView];

}
- (IBAction)playAnimation:(id)sender {
    if (_imageView.isAnimating) {
        [_imageView stopAnimating];//暂停播放
    }else{
        [_imageView startAnimating];//开始播放
    }
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

UILabel和UIImageView的使用

标签:uilabel   uiimageview   显示   对齐   

原文地址:http://blog.csdn.net/wow09_1225/article/details/46757637

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!