快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

UIView的使用-创新互联

#import "AppDelegate.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    //创建一个窗口对象,(UIEWindow),让窗口根屏幕一样大
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];  //属性是retain或者copy修饰,都要dealloc
    // Override point for customization after application launch.
    
    //给这个全屏的窗口设置一个颜色
    self.window.backgroundColor = [UIColor whiteColor];
    
      //把window设置为主窗口而且可见的,注意:一个应用程序只能显示一个window
    [self.window makeKeyAndVisible];
    
    //学习新类 -- 1.看继承关系  2.看新类没有没有自己的初始化方法/构造器
    
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(100, 150, 100, 130)];
    
    //设置属性
    view.backgroundColor = [UIColor grayColor];
    
    //让视图显示NO/隐藏YES
    //隐藏的时候,会吧view所有的子视图全部隐藏
    view.hidden = NO;
    
    //view透明度)0-1)
    view.alpha = 0.5;
    
    //将一个view添加到另一view上
    [_window addSubview:view]; //将view添加到window上 。
    NSLog(@"%@",view.superview);
    NSLog(@"111111%@",_window.subviews);
    
    //tag值  作用:方便父视图迅速找到某一子视图,tag值作为一个视图的标记
    view.tag = 1000;
    
    //重新调整view的位置和大小
    view.frame = CGRectMake(0, 0, 100, 100);
    
    //view的中心点,来调整view的位置
    view.center = CGPointMake(150, 200);
    
    //内存管理
    [view release];
    
    //重新创建一个view1
    UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(150, 250, 50, 100)];
    view1.backgroundColor = [UIColor blueColor];
    [_window addSubview:view1];
    [view1 release];
    
    //重新创建一个view2
    UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(200, 50, 50, 100)];
    view2.backgroundColor = [UIColor redColor];
    [_window addSubview:view2];
    [view2 release];
    //重新创建一个view2
    UIView *view3 = [[UIView alloc] initWithFrame:CGRectMake(60, 350, 200, 200)];
    view3.backgroundColor = [UIColor yellowColor];
    [_window addSubview:view3];
    [view3 release];
    
    UIView *view4 = [[UIView alloc] initWithFrame:CGRectMake(60, 350, 100, 100)];
    view4.backgroundColor = [UIColor greenColor];
    [_window addSubview:view4];
    [view4 release];
    
    
    //调整视图的层级关系
    
    //调整是由父视图来完成,可以对所有的子视图进行调整
    
    [_window bringSubviewToFront:view];  //把view[UIColor grayColor](灰色)的这个调整到最上面。。。。。
    
    //内存管理-------添加1
    [_window release];
    
    return YES;
}
//这里是因为属性用retain或者copy  -------添加2
- (void)dealloc
{
    [_window release];
    [super dealloc];
}
- (void)applicationWillResignActive:(UIApplication *)application
{
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application
{
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
@end

忻城网站制作公司哪家好,找创新互联公司!从网页设计、网站建设、微信开发、APP开发、响应式网站建设等网站项目制作,到程序开发,运营维护。创新互联公司于2013年创立到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选创新互联公司

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


名称栏目:UIView的使用-创新互联
分享URL:http://6mz.cn/article/decgsd.html

其他资讯