控件之间的基本关系(动态图片、字体的设置)UILable、UIImageView

本文详细介绍了iOS开发中如何进行UI布局设计,包括标签、按钮、文本框等控件的基本使用方法,以及如何利用帧动画实现界面的动态效果。通过实例演示,帮助开发者快速掌握iOS应用界面设计的核心技能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

/*

 1、把label对象给实例化,任何对象都要实例化

 2、给label设置frame

 3、把创建的视图放在父视图上面

 *控件之间的基本关系

 *UILabel

 *UIImageView

 */



#import "AppDelegate.h"


@interface AppDelegate ()


@end


@implementation AppDelegate



- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

//UIView显示一块有颜色的视图

    

    [self.windowmakeKeyAndVisible];

    

    

    /*

    UIView *view = [[UIView alloc]init];

    view.frame = CGRectMake(100, 100, 300, 300);

    view.backgroundColor;

    view.alpha;

    

    [self.window addSubview:view];

//    UILabel 标签控件:适合放一些短的文本。

//    UILabel继承与UIView

    UILabel *label = [[UILabel alloc]init];//label对象给实例化,任何对象都要实例化

    label.frame = CGRectMake(200, 200, 200, 80);//label设置frame

    label.text = @"ZKY第四期ios,1s2s2额手法而放弃飞额问题有问题有问题跳个舞问题问二哥我国";//UILabel设置文本

    label.textColor = [UIColor whiteColor];//textColor设置字体颜色

    label.backgroundColor = [UIColor redColor];

    label.textAlignment = NSTextAlignmentCenter;//UILabel设置对其方式

//UIColor

//UIFont

//  UIColor  UIFont都是一种类,用他们来创建的对象一样需要实例化

    UIFont *font = [UIFont systemFontOfSize:25];//系统默认字体,改变字体大小

//    label.font = font;

    

    label.font = [UIFont systemFontOfSize:13];//设置字体大小

    label.font = [UIFont boldSystemFontOfSize:16];//在加粗的同时设置字体大小

    label.font = [UIFont italicSystemFontOfSize:15];//在斜体的同时给字体设置大小

    label.shadowColor = [UIColor blackColor];//设置阴影颜色

    label.shadowOffset = CGSizeMake(5, 5);//设置阴影偏移量

//    label.numberOfLines = 0;//给内容设置行数,0代表自适应行数,非0,代表是几行就几行

    label.adjustsFontSizeToFitWidth = YES;//自适应字体,从而让内容尽量一行显示

    

    [self.window addSubview:label];//把创建的视图放在父视图上面

    

    */

    

    /*

     *创建帧动画四要素:

     1、设置间隔时间

     2、准备图片素材

     3、设置重复次数

     4、开始动画

     */

    UIImageView *imgeView = [[UIImageViewalloc]init];//UIImageView用来显示图片

//    imgeView.image = [UIImage imageNamed:@"1.tiff"];//如果图片是PNG格式的,图片名不需要加后缀,否则都要加。

    imgeView.frame = CGRectMake(10, 10, 50, 50);

    [self.windowaddSubview:imgeView];

    imgeView.animationDuration =0.01;//设置动画的时间间隔(默认时间秒)

//    imgeView.animationImages = @[@"1.tiff"];//

//    imgeView.animationRepeatCount;//

    UIImage *img1 = [UIImageimageNamed:@"1.tiff"];

    UIImage *img2 = [UIImageimageNamed:@"2.tiff"];

    UIImage *img3 = [UIImageimageNamed:@"3.tiff"];

    UIImage *img4 = [UIImageimageNamed:@"4.tiff"];

    NSArray *array = @[img1,img2,img3,img4];

    imgeView.animationImages = array;//给帧动画准备素材

    imgeView.animationRepeatCount =0;//给动画设置次数 0表示无数次

    [imgeView startAnimating];

    

    return YES;

}


// #define k常量名 @""

// 宏定义就是用内容替换变量名

#define kContent @"我改过的内容"

#define kLabelX label.frame.origin.x

#define kScreenWidth [UIScreen mainScreen].bounds.size.height


@interface AppDelegate ()


@end


@implementation AppDelegate



- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    

//    [self.window makeKeyAndVisible];

//    

//   

//    /*

//     * 控件之间的继承关系

//     * UILabel

//     * UIImageView

//     */

//    

//    //UIView显示一块有颜色的试图

//    UIView *view = [[UIView alloc]init];

//    view.frame = CGRectMake(100, 100, 300, 300);

//    [self.window addSubview:view];

//    

//    //UILable 标签控件,适合放一些

//    //短的文本。

//    //UILabel 继承于UIView

//    

//    //label对象给实例化,任何对象都要实例化

//    UILabel *label = [[UILabel alloc]init];

//    

//    //label设置frame

//    label.frame = CGRectMake(200, 200, 200, 150);

//    

//    //UILabel设置文本。

//    label.text = @"asasldjfsdklfjlsdfj";

//    

//

//    //textcolor设置字体颜色

//    label.textColor = [UIColor whiteColor];

//    

//    //UILabel设置对齐方式

//    label.textAlignment = NSTextAlignmentCenter;

//    

//

//    //UIFont UIColor都是一种类,用他们来创建的对象一样需要实例化。

//    //系统默认字体,并给设置字体大小

//    UIFont *font = [UIFont systemFontOfSize:25];

//

////    label.font = font;

//    

//    //在加粗的同时设置字体大小

////    label.font = [UIFont boldSystemFontOfSize:25];

//    

//    //在设置斜体的同时给设置字体大小

//    label.font = [UIFont italicSystemFontOfSize:25];

//    //shadowColor设置阴影并给设置阴影颜色

//    label.shadowColor = [UIColor blackColor];

//    

//    //设置阴影偏移量

//    label.shadowOffset = CGSizeMake(10, 10);

//

//    //给内容设置行数,0代表自适应行数,非0,是几就是几行

//    label.numberOfLines = 0;

//    

//    //自适应字体,从而让内容尽量一行显示

//    label.adjustsFontSizeToFitWidth = YES;

//    label.backgroundColor = [UIColor redColor];

//    

//    //要把咱创建的试图放在他的父试图上面

//    [self.window addSubview:label];

//    

//    //UIImageView用来显示图片

//    UIImageView *imgView = [[UIImageView alloc]init];


//

//    //如果图片是PNG格式的,图片名不需要加后缀,否则都要加

////    imgView.image = [UIImage imageNamed:@"程亚新.JPG"];

//    

//    imgView.frame = CGRectMake(10, 10, 300, 400);

//    

//    [self.window addSubview:imgView];

//    /*

//     * 创建帧动画四要素

//        1、设置间隔时间

//        2、准备图片素材

//        3、设置重复次数

//        4、开始动画

//     */

//    

//    

//    //animationDuration设置动画的时间间隔

//    imgView.animationDuration = 1;

//   

//    

//    UIImage *img1 = [UIImage imageNamed:@"程亚新.jpg"];

//    

//    UIImage *img2 = [UIImage imageNamed:@"张天.JPG"];

//

//    NSArray *array = @[img1,img2];

//    

//    //给帧动画准备素材

//    imgView.animationImages = array;

//    

//    //给动画设置重复次数

//    imgView.animationRepeatCount = 0;

//

//    [imgView startAnimating];

  

    //    imgView.contentMode

    //    CGRectGetHeight(<#CGRect rect#>)

    

//        [UIScreen mainScreen].bounds.origin

        //宏定义

    

    

//    

//    [self.window makeKeyAndVisible];

//    

//    

//    UIImageView *imgView = [[UIImageView alloc]init];

//    

//    imgView.frame = CGRectMake(10, 10, 300, 300);

//    imgView.image = [UIImage imageNamed:@"张天.jpg"];

//    imgView.contentMode = UIViewContentModeCenter;

//    imgView.clipsToBounds = YES;

//    

//    imgView.backgroundColor = [UIColor blackColor];

//    

//    [self.window addSubview:imgView];

//    

//    NSLog(@"%f",CGRectGetHeight(imgView.frame));

//    

#pragma mark 补充

    /*

     

     * 延迟方法

     

     * CGRectGetHeight(<#CGRect rect#>)

    

     * [UIScreen mainScreen].bounds.origin

     

     * 宏定义

     

     * 宏定义的使用技巧

     

     * 补充

     

    */

    

    //延迟多少秒后执行相应的方法,用selector选择的方法一定要实现,否则会崩溃。

    

    [self.windowmakeKeyAndVisible];

    [selfperformSelector:@selector(start)withObject:nilafterDelay:5];

    

    UILabel *label = [[UILabelalloc]init];

    

    label.frame = CGRectMake(10, 20, 120, 49);

    

    label.backgroundColor = [UIColorredColor];

    

    label.text = kContent;

    

    label.shadowColor = [UIColorwhiteColor];

    label.shadowOffset = CGSizeMake(-1, -1);

    [self.windowaddSubview:label];


//    //第一种方式

//    NSLog(@"labelx=%f",kLabelX);

//    //第二种方式

//    NSLog(@"labelheight=%f",CGRectGetWidth(label.frame));

    

    //UIScreen指的就是屏幕,能帮组我们获取到各种屏幕的宽和高

    NSLog(@"屏幕的高=%f",kScreenWidth);

    

    

    UIImageView *imgeView = [[UIImageViewalloc]init];

    imgeView.frame = CGRectMake(30, 30, 300, 400);

    imgeView.backgroundColor = [UIColorgrayColor];

    imgeView.image = [UIImageimageNamed:@"张天.JPG"];

    

    //在某个方向上让图片自适应,已达到最好看的效果。

    imgeView.contentMode =UIViewContentModeScaleAspectFit;

    

    //让图片充满整个frame

    imgeView.contentMode =UIViewContentModeScaleToFill;

    //取到图片的相应位置,并放到屏幕上,会超出设置的图片试图Frame

    imgeView.contentMode =UIViewContentModeRight;

    

    //裁剪掉超出试图frame的部分

    imgeView.clipsToBounds = YES;

    

    [self.windowaddSubview:imgeView];

    

    

    return YES;

}


- (void)start{

    

    

}



内容概要:本文档提供了关于“微型车间生产线的设计与生产数据采集试验研究”的毕业设计复现代码,涵盖从论文结构生成、机械结构设计、PLC控制系统设计、生产数据采集与分析系统、有限元分析、进度管理、文献管理和论文排版系统的完整实现。通过Python代码和API调用,详细展示了各个模块的功能实现和相互协作。例如,利用SolidWorks API设计机械结构,通过PLC控制系统模拟生产流程,使用数据分析工具进行生产数据的采集和异常检测,以及利用进度管理系统规划项目时间表。 适合人群:具有机械工程、自动化控制或计算机编程基础的学生或研究人员,尤其是从事智能制造领域相关工作的人员。 使用场景及目标:①帮助学生或研究人员快速搭建和理解微型车间生产线的设计与实现;②提供完整的代码框架,便于修改和扩展以适应不同的应用场景;③作为教学或科研项目的参考资料,用于学习和研究智能制造技术。 阅读建议:此资源不仅包含详细的代码实现,还涉及多个学科领域的知识,如机械设计、电气控制、数据分析等。因此,在学习过程中,建议读者结合实际操作,逐步理解每个模块的功能和原理,并尝试调整参数以观察不同设置下的系统表现。同时,可以参考提供的文献资料,深入研究相关理论和技术背景。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值