zoukankan      html  css  js  c++  java
  • ios UIImage

     1 //
     2 //  ViewController.h
     3 //  05-图片浏览器
     4 //
     5 //  Created by zjj on 15/5/5.
     6 //  Copyright (c) 2015年 zjj. All rights reserved.
     7 //
     8 
     9 #import <UIKit/UIKit.h>
    10 
    11 @interface ViewController : UIViewController
    12 
    13 - (IBAction)setting;
    14 - (IBAction)siderValueChange:(UISlider *)sender;
    15 @property (weak, nonatomic) IBOutlet UIImageView *imageView;
    16 @property (weak, nonatomic) IBOutlet UILabel *imageDesc;
    17 @property (weak, nonatomic) IBOutlet UILabel *imageNo;
    18 @property (weak, nonatomic) IBOutlet UIView *settingView;
    19 - (IBAction)imageSizeChange:(UISlider *)sender;
    20 - (IBAction)nightMode:(UISwitch *)sender;
    21 
    22 @end
      1 //
      2 //  ViewController.m
      3 //  05-图片浏览器
      4 //
      5 //  Created by zjj on 15/5/5.
      6 //  Copyright (c) 2015年 zjj. All rights reserved.
      7 //
      8 
      9 #import "ViewController.h"
     10 
     11 @interface ViewController ()
     12 {
     13     NSArray *_addDess;// 成员变量,只要对象在 控制器在该变量就存在
     14 }
     15 @end
     16 
     17 @implementation ViewController
     18 
     19 - (void)viewDidLoad {
     20     [super viewDidLoad];
     21     // Do any additional setup after loading the view, typically from a nib.
     22     // 通过plist文件获取字符串数组
     23     // 获得所有描述 (通过解析plist文件来创建数组对象,比如传入文件的全路径)
     24     // 如果要访问项目中资源包里面的所有资源应该使用mainBundle
     25     NSBundle *bundel = [NSBundle mainBundle];
     26     // 获得文件全路径
     27     NSString *path=[bundel pathForResource:@"descs" ofType:@"plist"];
     28     // 加载path对应文件来创建数组
     29      _addDess = [NSArray arrayWithContentsOfFile:path];
     30     //设置默认描述
     31     _imageDesc.text = _addDess[0];
     32 }
     33 
     34 - (void)didReceiveMemoryWarning {
     35     [super didReceiveMemoryWarning];
     36     // Dispose of any resources that can be recreated.
     37 }
     38 #pragma mark 点击设置
     39 - (IBAction)setting {
     40     [UIView beginAnimations:nil context:nil];
     41     [UIView setAnimationDuration:1.0];
     42    CGPoint tempCenter = _settingView.center;
     43 
     44     if (_settingView.frame.origin.y == self.view.frame.size.height) {
     45         //    tempCenter.y -= _settingView.center.y;
     46     tempCenter.y -= _settingView.bounds.size.height;
     47     }else
     48     {
     49     tempCenter.y += _settingView.bounds.size.height;
     50     }
     51     _settingView.center = tempCenter;
     52     [UIView commitAnimations];
     53 }
     54 #pragma mark slider 滑动进度条显示图片
     55 - (IBAction)siderValueChange:(UISlider *)sender {
     56     // 设置图片 %.f 不保留任何小数
     57     NSString *imgPath =[NSString stringWithFormat:@"%.f.png",sender.value] ;
     58     _imageView.image = [UIImage imageNamed:imgPath];
     59     // 设置序号
     60     _imageNo.text = [NSString stringWithFormat:@"%.f/16",sender.value+1];
     61     // 设置文字
     62 //    NSArray *desc =
     63 //    @[
     64 //     @{@"depict":@"1还有比这更纠结的表情么"},
     65 //     @{@"depict":@"2"},
     66 //     @{@"depict":@"3hoho"},
     67 //     @{@"depict":@"4wowo"},
     68 //     @{@"depict":@"5还有比这更纠结的表情么"},
     69 //     @{@"depict":@"6hahah"},
     70 //     @{@"depict":@"7hoho"},
     71 //     @{@"depict":@"8wowo"},
     72 //     @{@"depict":@"9还有比这更纠结的表情么"},
     73 //     @{@"depict":@"10hah10ah"},
     74 //     @{@"depict":@"11hoho"},
     75 //     @{@"depict":@"12wowo"},
     76 //     @{@"depict":@"13hoho"},
     77 //     @{@"depict":@"14hahah"},
     78 //     @{@"depict":@"15hoho"},
     79 //     @{@"depict":@"16wowo"}
     80 //     ];
     81 
     82 //     _imageDesc.text = desc[(int) sender.value][@"depict"] ;
     83 // flot 强制转换成整数四舍五入bug修正
     84     _imageDesc.text =  _addDess[(int)(sender.value + 0.5)];
     85 }
     86 //滑动缩放
     87 - (IBAction)imageSizeChange:(UISlider *)sender {
     88     _imageView.transform = CGAffineTransformMakeScale(sender.value, sender.value);
     89 }
     90 //夜间模式
     91 - (IBAction)nightMode:(UISwitch *)sender {
     92     if (sender.on) {
     93         self.view.backgroundColor = [UIColor darkGrayColor];
     94     }
     95     else
     96     {
     97        self.view.backgroundColor = [UIColor whiteColor];
     98     }
     99 }
    100 @end

  • 相关阅读:
    随笔为什么还要想标题
    [GXYCTF2019]BabySQli
    [CISCN2019 华北赛区 Day2 Web1]Hack World
    20年美亚杯个人赛-ALICE_USB部分WRITE UP
    20年美亚杯个人赛-Alice LG Phone部分WRITE UP
    20年美亚杯个人赛-Alice_Laptop部分WRITE UP
    20年美亚杯WRITE UP
    18年美亚杯团体赛-C部分 WRITE UP
    v&n赛 ML 第一步(python解决)
    CTFHub web技能树 RCE
  • 原文地址:https://www.cnblogs.com/zhangdashao/p/4481706.html
Copyright © 2011-2022 走看看