一:UIButton
1: 添加图片 setImage
2: 添加响应处理 addTarget
如:
UIButton* btnClose = [[UIButton alloc]initWithFrame:CGRectMake(CLOSE_BTN_RELEATE_SVC_OFFEST_X,
CLOSE_BTN_RELEATE_SVC_OFFEST_Y,
CLOSE_BTN_WIDTH,
CLOSE_BTN_HEIGHT)];
[btnClose addTarget:self.delegate action:@selector(pressCloseShareViewControllerClicked:) forControlEvents:UIControlEventTouchUpInside];
[btnClose setImage:[UIImage imageNamed:@"closeUnsel.png"] forState:UIControlStateNormal];
[btnClose setImage:[UIImage imageNamed:@"closeSel.png"] forState:UIControlStateHighlighted];
[self.view addSubview:btnClose];
二:UIScrollView
重要的属性:显示方式及显示可以容纳的大小。
m_svCategory = [[UIScrollViewalloc]initWithFrame:CGRectMake(nSVCategoryStartX,
lableCategory.frame.origin.y,
szCatVis.width,
szCatVis.height)]; //定义可以可视宽,高。
m_svCategory .showsHorizontalScrollIndicator = YES ; //显示方式m_svCategory.contentSize =CGSizeMake(m_svCategory.frame.size.width,m_svCategory.frame.size.height);//定义可以容纳的大小
[self.viewaddSubview:m_svCategory];
UIScrollView中可以放置UIButton等控件。
三:UITextField
如何让其在输入数字的时候用密码(星号)方式显示:
UITextField *tfPassword = [[UITextFieldalloc]initWithFrame:CGRectMake(tfUserName.frame.origin.x,
tfUserName.frame.origin.y+tfUserName.frame.size.height+DIFF_HEIGHT,
150,
25)];
tfPassword.adjustsFontSizeToFitWidth =YES;
tfPassword.secureTextEntry =YES;//密码方式
[tfPasswordsetBackgroundColor:[UIColorlightGrayColor]];
[self.viewaddSubview:tfPassword];
四:UILabel
加入的文字如何显示出透明背景:
UILabel *saveAndShareLabel = [[UILabelalloc]initWithFrame:CGRectMake(SAVE_AND_SHARE_LABEL_RELEATE_SVC_OFFEST_X,
SAVE_AND_SHARE_LABEL_RELEATE_SVC_OFFEST_Y,
SAVE_AND_SHARE_WIDTH,
SAVE_AND_SHARE_HEIGHT)];
[saveAndShareLabel setFont:[UIFont systemFontOfSize:TITLE_LABEL_FONT_SIZE]];
[saveAndShareLabel setText:@"保存分享"];
saveAndShareLabel.backgroundColor = [UIColorclearColor]; //UIColor clearColor擦除原来的颜色,这样背景就透明了。
[self.viewaddSubview:saveAndShareLabel];
五:UIViewController.
1:一个UIViewController如何加入另外一个UIViewController.(self.view addSubView: UIViewController.view).
如:
- (void)viewDidLoad
{
[super viewDidLoad];
m_bClothesShowToStage = NO;
m_bShowShareView = NO;
m_nPreClothesTag = -1;
//RootViewController 设置背景颜色及框架大小
self.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"stageBg.png"]];
[self.view setFrame:CGRectMake(ROOT_VIEW_CONTROLLER_ORIGIN_X,
ROOT_VIEW_CONTROLLER_ORIGIN_Y,
ROOT_VIEW_CONTROLLER_WIDTH,
ROOT_VIEW_CONTROLLER_HEIGHT)];
//添加toolbar viewcontroller
self.toolbarViewController = [[SSToolBarViewController alloc] init];
[self.toolbarViewController.view setFrame:CGRectMake(TOOLBAR_VIEW_CONTROLLER_RELEATE_RVC_OFFEST_X,
TOOLBAR_VIEW_CONTROLLER_RELEATE_RVC_OFFEST_Y,
TOOLBAR_VIEW_CONTROLLER_WIDTH,
TOOLBAR_VIEW_CONTROLLER_HEIGHT)];
// [self.toolbarViewController addToolBtn:array];
self.toolbarViewController.delegate = self;//设置委托
[self.view addSubview:self.toolbarViewController.view];//RootViewController加入了SSToolBarViewController.
六:手势动作
1:有一个具体的view,继承于UIView.
2: 将这个具体的View与你期望的手势进行绑定。手势基类:UIGestureRecognizer。
如:
SSStageView *subview = [[SSStageView alloc]init:rc withAreaId:nAreaId withWarnRect:swf.rc withBgImageTag:i];
[self addSwipeGestureToView:subview];
-(void)addSwipeGestureToView:(UIView*) view {
UISwipeGestureRecognizer *swipeGesRec = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(handleSwipe:)];
[view addGestureRecognizer:swipeGesRec];//将view与手势相绑定,一旦触发,handleSwipe触发函数就会被调用。
}
七:如何给控件周围标识选中框
加入适当的头文件:<QuartzCore/QuartzCore.h> 及相应的类库:QuartzCore.framework
for(UIButton* btn in m_arrAreaBtn)
{
btn.layer.cornerRadius = 4.5f;
btn.layer.borderWidth = 1;
btn.layer.borderColor = [UIColor redColor].CGColor;
nSelAreaId = nNewAreaId;
}
选中Standard Editor中相应的工程名。然后选中右边Targets下工程名,Summary标签项。确定选择了准确的部署设备,版本等。
1;开发者账号填写:
Bundle Identifier前缀与你申请的开发者账号保持一致,
除此之外,还需要选择Build Settings,选中里面的Code Signing, 填写准确的开发者账号,否则不能成功运行。
具体安装证书过程可以在网上查找一下。
2:添加库操作:
summary->Linked Frameworks and Libraries.里面的加号,如果要删除,只能是去Standard Editor,选者需要删除的类库文件。
或是选择:Build Phases-> Link Binary With Libraries.
3:如果工程使用的是ARC方式,而加入的第三方采用的是 非ARC 编码,这样在编译,链接的时候就会出现问题。为了使其两者相互保持兼容,可以
Build Phases->Compile Sources打开,然后对 非ARC编码 文件添加编译标志:-fno-objc-arc