#import "ViewController.h"app
@interface ViewController ()atom
@end 加密
@implementation ViewControllerspa
- (void)viewDidLoad {.net
[super viewDidLoad];3d
//實例化一個列表對象UITableView對象代理
UITableView *tableView=[[UITableView alloc]initWithFrame:[[UIScreen mainScreen]bounds] style:UITableViewStylePlain];//UITableViewStylePlain是控件UITableView的樣式。能夠選擇的設置樣式有兩種:UITableViewStylePlain和UITableViewStyleGroupedorm
// [[UIScreen mainScreen]bounds]是獲取整個屏幕的方法,返回爲CGRect對象
//設置代理和數據源get
tableView.delegate=self;
tableView.dataSource=self;
//將控件添加到頁面上
[self.view addSubview:tableView];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
//UITableView的代理協議UITableViewDataSourse中的必要實現方法之一。用來設置列表每組的行數
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
if (section==2) {
return 3;
}
return 5;
}
//UITableView的代理協議UITableViewDataSourse中的必要實現方法之一。用來設置cell的數據
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"cell"];
if (cell == nil) {
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];//UITableViewCellStyleSubtitle是UITableViewCell的樣式設置
}
cell.textLabel.text=@"hello";//設置行的內容
cell.detailTextLabel.text=@"hi";//設置行的副標題內容
return cell;
}
//設置tableView有多少組
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 4;
}
//設置UITableView的每組標題的內容
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
return @"頭部標題";
}
//設置尾部標籤的內容
- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section{
return @"尾部標題";
}
@interface ViewController : UIViewController<UITableViewDelegate,UITableViewDataSource>
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property(nonatomic,strong)UIImageView *imageViewIII;
@end
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// UIImageView *imageView=[[UIImageView alloc]init];
UIImageView *imageViewI=[[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 200, 200)];
imageViewI.image=[UIImage imageNamed:@"0"];
// [self.view addSubview:imageViewI];
UIImageView *imageViewII=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"4"]];
imageViewII.frame=CGRectMake(180, 100, 100, 100);
// [self.view addSubview:imageViewII];
// [self.view bringSubviewToFront:imageViewI];
_imageViewIII=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"4"] highlightedImage:[UIImage imageNamed:@"5"]];
_imageViewIII.frame=CGRectMake(20,300, 300, 200);
// _imageViewIII.highlighted=YES;
_imageViewIII.userInteractionEnabled=YES;
UITapGestureRecognizer *gestur=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(fangFa)];
[_imageViewIII addGestureRecognizer:gestur];
// _imageViewIII.center=CGPointZero;
_imageViewIII.bounds=CGRectMake(0, 0, 100, 100);
//
//
_imageViewIII.backgroundColor=[UIColor redColor];
_imageViewIII.contentMode=UIViewContentModeLeft;
_imageViewIII.transform=CGAffineTransformMakeTranslation(100, 200);
[self.view addSubview:_imageViewIII];
}
-(void)fangFa{
NSLog(@"weqeqw");
// _imageViewIII.highlighted=YES;
_imageViewIII.transform=CGAffineTransformMakeRotation(M_PI*90/180);
_imageViewIII.transform=CGAffineTransformMakeScale(0.2, 0.5);
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
//加密 解密
@autoreleasepool {
NSString *str=@"kjBYYIklnBVY";
NSMutableString *jiami=[[NSMutableString alloc]init];
NSMutableArray *array = [[NSMutableArray alloc]init];
for (int i=0; i<[str length]; i++) {
char s=[str characterAtIndex:i];
int i=(int) s+1;
[array addObject:[NSString stringWithFormat:@"%i",i-1]];
if(i< 97){
i += 32;
}
char c = (char) i;
[jiami appendFormat:@"%c",c];
}
NSLog(@"加密後:%@",jiami);
NSMutableString *jiemi=[[NSMutableString alloc]init];
for (int i=0; i<[array count]; i++) {
int a=[array[i] intValue];
[jiemi appendString:[NSString stringWithFormat:@"%c",(char)a]];
}
NSLog(@"解密後:%@",jiemi);
}
return 0;