简单的框架

s




AppDelegate.m文件中简单的初始化

//

// RootViewController.m

// test

//

// Created by kuangkuang on 13-9-26.

// Copyright (c) 2013年 kuangkuang. All rights reserved.

//



#import "RootViewController.h"

#import <QuartzCore/QuartzCore.h>

#import "Boundblock.h"

@interface RootViewController ()



@property(nonatomic,retain)UIView *block;

@property(nonatomic,retain)Boundblock *boundblock;

@end



@implementation RootViewController



- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

{

self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

if (self) {

// Custom initialization

}

return self;

}



-(void)btncilck:(UIButton *)sender{



[self.boundblock moveBlockTo:sender.frame.origin.x];



}

-(void)buildlayout{



self.view.backgroundColor=[UIColor colorWithRed:0.4 green:0.3 blue:0.8 alpha:0.6];

#define BTN_COUNT 3

#define BTN_WIDTH 320/BTN_COUNT



for (int i=0; i<BTN_COUNT; i++) {

UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom];

btn.frame=CGRectMake(BTN_WIDTH*i, CGRectGetHeight(self.view.bounds)-40, BTN_WIDTH, 40);

[btn setTitle:[NSString stringWithFormat:@"btn%d",i+1] forState:UIControlStateNormal];

//btn.backgroundColor=[UIColor clearColor];

//[btn setBackgroundColor:[UIColor redColor]];

btn.layer.borderColor=[UIColor redColor].CGColor;

btn.layer.borderWidth=0.7;

[btn addTarget:self action:@selector(btncilck:) forControlEvents:UIControlEventTouchUpInside];

[self.view addSubview:btn];



}

self.boundblock=[[Boundblock alloc]initWithFrame:CGRectMake(0,CGRectGetHeight(self.view.bounds)-50,320,10) blockCount:BTN_COUNT];

self.boundblock.backgroundColor=[UIColor whiteColor];



[self.view addSubview:self.boundblock];



}

- (void)viewDidLoad

{

[super viewDidLoad];

[self buildlayout];

// Do any additional setup after loading the view.

}



- (void)didReceiveMemoryWarning

{

[super didReceiveMemoryWarning];

// Dispose of any resources that can be recreated.

}



@end






#import <UIKit/UIKit.h>



@interface Boundblock : UIView



-(id)initWithFrame:(CGRect)frame blockCount:(NSInteger)count;

-(void)moveBlockTo:(CGFloat)x;

@end




//

// Boundblock.m

// test

//

// Created by kuangkuang on 13-9-26.

// Copyright (c) 2013年 kuangkuang. All rights reserved.

//



#import "Boundblock.h"

#import "RootViewController.h"

#import <QuartzCore/QuartzCore.h>



@interface Boundblock ()

@property(nonatomic,retain)UIView *block;



@end



@implementation Boundblock



-(void)moveBlockTo:(CGFloat)x{



__block CGRect targetFrame=self.block.frame;

BOOL directionRight=targetFrame.origin.x<x;





targetFrame.origin.x=x+(directionRight?20:-20);





[UIView animateWithDuration:0.1 animations:^{

self.block.frame=targetFrame;

}completion:^(BOOL finished) {

targetFrame.origin.x+=directionRight?-40:40;

[UIView animateWithDuration:0.1 animations:^{

self.block.frame=targetFrame;

} completion:^(BOOL finished) {

targetFrame.origin.x+=directionRight?20:-20;

[UIView animateWithDuration:0.1 animations:^{

self.block.frame=targetFrame;

}];

}];

}];



}



-(id)initWithFrame:(CGRect)frame blockCount:(NSInteger)count{



self=[super initWithFrame:frame];

if (self) {



UIView *bglayer=[[UIView alloc]initWithFrame:self.bounds];

bglayer.backgroundColor=[UIColor darkGrayColor];

bglayer.layer.opacity=0.4;

[self addSubview:bglayer];





self.block=[[UIView alloc]initWithFrame:CGRectMake(0,0,frame.size.width/count,frame.size.height)];

self.block.backgroundColor=[UIColor orangeColor];

self.block.layer.opacity=1;

[self addSubview:self.block];

}

return self;

}



- (id)initWithFrame:(CGRect)frame

{

return [self initWithFrame:frame blockCount:5];

}



@end



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Unity UI框架是一种用于创建用户界面(UI)的工具集和组件集合。它提供了丰富的UI元素和功能,可以帮助开发者轻松地构建交互性和可视化的界面。 Unity UI框架可以通过Unity Asset Store进行下载。打开Unity编辑器,点击"Window"菜单,选择"Asset Store"选项,会打开Asset Store窗口。在搜索栏中输入"Unity UI框架",可以找到很多可用的UI框架。 在选择和下载UI框架之前,开发者应该了解项目的需求并进行评估。可以根据项目的规模、复杂度和用户需求来选择合适的UI框架。一些常用的UI框架包括:"TextMeshPro"、"DOTween" 和 "UGUI"等。开发者可以根据自己的需要选择适合的框架。 下载UI框架后,可以将其导入到Unity项目中。在Asset Store或者Unity Package Manager中选择合适的UI框架,点击"Download" 或者 "Import"按钮进行安装。安装完成后,可以在Unity编辑器的"Assets"文件夹中找到导入的UI框架。 使用UI框架时,可以在Unity编辑器中创建UI元素,如按钮、文本、滑动条等,并对其进行布局和样式设置。可以通过脚本代码来实现交互性功能,如按钮的点击事件、输入框的文本处理等。UI框架还提供了很多可定制的功能和效果,如动画、过渡和绘制等,可以增强用户界面的视觉效果和交互体验。 总之,Unity UI框架是一个方便使用的工具集,可以帮助开发者快速构建用户界面。通过下载合适的UI框架,开发者可以轻松地创建、布局和管理UI元素,提供良好的用户体验。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值