Xcode中怎么做登陆界面

最低Xcode5.0开发环境,storyboard,界面设计,做登陆界面,求大神指教。。。... 最低Xcode 5.0开发环境,storyboard,界面设计,做登陆界面,求大神指教。。。 展开
 我来答
shihoumacili
高粉答主

推荐于2016-04-02 · 每个回答都超有意思的
知道大有可为答主
回答量:1.1万
采纳率:87%
帮助的人:527万
展开全部

现在xcode新建的项目都是自带故事板的,操作不是很方便,来把它改成说写代码

打开AppDelegate.h文件,添加以下代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window=[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.window.rootViewController=[[ViewController alloc] init]; [self.window makeKeyAndVisible]; return YES; }

到此就完成了手写代码的第一步。

添加输入框和按钮

在ViewController.h中添加以下代码

#import "ViewController.h"
@interface ViewController ()
@property (nonatomic,strong) UITextField *account;
@property (nonatomic,strong) UITextField *password;
@property (nonatomic,strong) UIButton *loginButton;
@end
@implementation ViewController
- (void)viewDidLoad {
   [super viewDidLoad];
   [self.view setBackgroundColor:[UIColor colorWithRed:51/255.0 green:204/255.0 blue:255/255.0 alpha:1]];
   _account=[[UITextField alloc] initWithFrame:CGRectMake(20, 200, self.view.frame.size.width-40, 50)];
   _account.backgroundColor=[UIColor whiteColor];
   _account.placeholder=[NSString stringWithFormat:@"Email"];
   [self.view addSubview:_account];
   _password=[[UITextField alloc] initWithFrame:CGRectMake(20, 260, self.view.frame.size.width-40, 50)];
   _password.backgroundColor=[UIColor whiteColor];
   _password.placeholder=[NSString stringWithFormat:@"Password"];
   [self.view addSubview:_password];
   _loginButton=[UIButton buttonWithType:UIButtonTypeRoundedRect];
   [_loginButton setFrame:CGRectMake(20, 320, self.view.frame.size.width-40, 50)];
   [_loginButton setTitle:@"Login" forState:UIControlStateNormal];
   [_loginButton setBackgroundColor:[UIColor colorWithRed:51/255.0 green:102/255.0 blue:255/255.0 alpha:1]];
   [_loginButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
   [self.view addSubview:_loginButton];
}
@end

运行一下看看效果

AiPPT
2024-09-19 广告
随着AI技术的飞速发展,如今市面上涌现了许多实用易操作的AI生成工具1、简介:AiPPT: 这款AI工具智能理解用户输入的主题,提供“AI智能生成”和“导入本地大纲”的选项,生成的PPT内容丰富多样,可自由编辑和添加元素,图表类型包括柱状图... 点击进入详情页
本回答由AiPPT提供
匿名用户
2014-09-30
展开全部
把控件一一排列整齐,点击按钮触发一个事件,用于连接服务器或数据库判断用户名和密码就好了。
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式