IOS开发之视图边框和切圆角


#import "AppDelegate.h"app


@interface AppDelegate ()ide


@end spa


@implementation AppDelegate.net



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

    // Override point for customization after application launch.orm

    

     _window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];继承

    

    [_window setBackgroundColor:[UIColor whiteColor]];图片

    

    //======================================get

    UIView *view = [[UIView alloc]initWithFrame:animation

                    CGRectMake(100, 100, 100, 100)];

    //系统提供的全部的视图类都是直接或者间接继承自UIView

    //能够显示内容

    

    //显示内容的实质是由于UIView类中提供了不一样的draw方法;

    //全部的视图都有形状,形状是由layer决定的;每一个视图都有layer;

    

    //若是想要改变视图的形状,必须经过layer去改变;

    

    view.backgroundColor = [UIColor orangeColor];

    

    //2.切圆角

    //参数就是圆角半径

    [view.layer setCornerRadius:50];

    

    //切圆角若是是带切图片的控件,必须带上如下代码有效

    view.layer.masksToBounds = YES;

    

    //3.画边框

    //设置边框宽度

    view.layer.borderWidth = 2;

    //设置边框颜色

    [view.layer setBorderColor:[UIColor greenColor].CGColor];

    

    [UIView animateWithDuration:2 animations:^{

       

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

        

        //若是设置了layer就不能经过frame改变视图的大小,

        //只能经过形变去改变大小

        view.transform = CGAffineTransformMakeScale(0.5, 0.5);

        

    }];

    

    [_window addSubview:view];

    [_window makeKeyAndVisible];

    


    

    

    return YES;

}

相关文章
相关标签/搜索