今天刚好需要添加一个圆角的view. 必须先导入头文件. #import <QuartzCore/QuartzCore.h> bgView.layer.cornerRadius = cornerRadiusInPixels;//设置角度大小 bgView.layer.masksToBounds = YES; bgView.opaque = NO;…
不可滑动: ? 1 tableView.userInteractionEnabled = NO; 也可以在storyboard中的userInteractionEnable属性设置 显示导向箭头: ? 1 2 // 显示导向箭头 cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 自定义按钮: ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 - (…
在ios中,rootview为PassWordViewController,secondview为SecondViewController,实现在rootview中听过一个跳转按钮实现跳转到secondview中,实现方法如下: 在PassWordViewController.h中添加button的事件 -(IBAction) landButtonPressed:(id) sender; 在PassWordViewController.m中 button的实现事件如下: -(IBAction)…
一. 前言 对于在 MVC 的定义中,view 层是不引用 model 层,view 和 model 是不相往来的 一般开发中,我们都写过 在自定义 view 中增加一个 model 的属性,外接直接传个 model 来,在 view 中 model 的 set 方法里对 view 的控件赋值的代码,例如在自定义 UITableViewCell 时用的很多,此时 view 是直接引用了 model 基于封装的思想,我们需要竟可能的复用我们的代码,复用我们的 view,这时我们需要进行解耦,不依赖…
1,创建UIView 的SubClass 命名为MyView 2, new一个名为MyView的xib p1 3,配置xib的属性 p2 4,为View 添加背景色,添加一个按钮并定制按钮约束,这里我添加的约束为垂直居中,Button与View等宽,Button左边起点位置为0. p3 5,设置xib中的File’s owner = MyView, 拖拽view 到关联的代码中命名为contentView p4 6, 在storyboard 中对ViewController 添加一个View,之…
一.封装一个View的思路 1.将View内部的业务逻辑(显示内容)封装到View中 2.一般情况下,View的位置应该由父控件来决定,也就是位置不应该固定死在View内部 3.至于View的宽高,根据具体情况来决定要不要由父控件决定…
项目中用到地图设置渐变色,查找资料找到两种方法:一种设置颜色,一种设置透明度: //为颜色设置渐变效果: UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)]; CAGradientLayer *gradient = [CAGradientLayer layer]; //设置开始和结束位置(设置渐变的方向) gradient.startPoint = CGPointMake(0, 0); gradient.e…
@interface ViewController () @property(nonatomic,retain)UIView *redview; @property(nonatomic,retain)UIView *yellowview; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; self.redview=[[UIView alloc] initWithFrame:CGRectMa…
-(void)viewMethod{ //1: 要明白uiview内部是这样实现 CALayer *layer1= [CALayer layer]; layer.delegate=self; [layer1 setNeedsDisplay]; [self.layer addSublayer:layer]; } - (void)drawRect:(CGRect)rect { //contex和ctx是相同的,所以在view画的东西都在上下文中. CGContextRef context= UIGr…
本文将介绍如何创建类似Facebook和Path iOS程序中的滑出式导航面板. 向右滑动 滑出式设计模式可以让开发者在程序中添加常用的导航功能,又不会浪费屏幕上宝贵的空间.用户可以在任意时间滑出导航面板,并且还可以看到当前屏幕上显示的内容. 现在,互联网上有些库已经内置滑出式设计模式,比如John-Lluch开发的SWRevealViewController.如果你在寻找更加快捷和简单的方法,那么使用SWRevealViewController库可能是一个很不错的方法. 不过,如果你是一名DI…