本文主要介绍 iOS编程。一部分界面控件编程。主要实现两个简单的小程序,一个是显示输入内容的小程序,一个是浏览图片的小程序。
操作系统平台:macBook(macOS)
IDE:Xcode
编程语言:Objective-C
一:UILabel(标签控件),UIButton(按钮控件),UITextField(文本框控件)
1.程序效果
2.程序代码
ViewController.m
#import "ViewController.h"
@interface ViewController ()
@property (strong, nonatomic) IBOutlet UILabel *blueLabel;
@property (strong, nonatomic) IBOutlet UITextField *inputtext;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self.view setBackgroundColor:[UIColor cyanColor]];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)okbutton:(UIButton *)sender {
self.blueLabel.text=self.inputtext.text;
self.inputtext.text=@"";
}
@end
二:UIImageView(图像控件)
1.程序效果
2.程序代码
UIImageView(图像控件代码)
self.image1=[[UIImageView alloc] initWithFrame:CGRectMake(0,10,sizeview.width,sizeview.height)];
[self.view addSubview:self.image1];
self.image1.image=[UIImage imageNamed:@"1.jpg"];
self.image1.contentMode=UIViewContentModeScaleAspectFit;
self.image1.userInteractionEnabled=YES;
三:视频效果
macbook下,ios界面编程
以上内容仅供参考,如有不对,欢迎指正。
首次编辑:2025/03/01 10:32