add .gitignore

This commit is contained in:
JoyWayer
2023-12-27 20:38:37 +08:00
parent b106a628a5
commit f6343426d6
515 changed files with 104217 additions and 199 deletions

View File

@@ -0,0 +1,26 @@
//
// ChatRecorderView.h
// Jeans
//
// Created by Jeans on 3/24/13.
// Copyright (c) 2013 Jeans. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface ChatRecorderView : UIView
@property (retain, nonatomic) IBOutlet UIImageView *peakMeterIV;
@property (retain, nonatomic) IBOutlet UIView *background;
@property (retain, nonatomic) IBOutlet UILabel *countDownLabel;
//还原界面
- (void)restoreDisplay;
//更新音频峰值
- (void)updateMetersByAvgPower:(float)_avgPower;
@end

View File

@@ -0,0 +1,114 @@
//
// ChatRecorderView.m
// Jeans
//
// Created by Jeans on 3/24/13.
// Copyright (c) 2013 Jeans. All rights reserved.
//
#import "ChatRecorderView.h"
@interface ChatRecorderView(){
NSArray *peakImageAry;
}
@end
@implementation ChatRecorderView
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self initilization];
}
return self;
}
- (id)initWithCoder:(NSCoder *)aDecoder{
self = [super initWithCoder:aDecoder];
if (self) {
[self initilization];
}
return self;
}
- (void)initilization{
//peak
peakImageAry = [[NSArray alloc]initWithObjects:
[UIImage imageNamed:@"record_animate_01.png"],
[UIImage imageNamed:@"record_animate_02.png"],
[UIImage imageNamed:@"record_animate_03.png"],
[UIImage imageNamed:@"record_animate_04.png"],
[UIImage imageNamed:@"record_animate_05.png"],
[UIImage imageNamed:@"record_animate_06.png"],
[UIImage imageNamed:@"record_animate_07.png"],
[UIImage imageNamed:@"record_animate_08.png"],
[UIImage imageNamed:@"record_animate_09.png"],
[UIImage imageNamed:@"record_animate_10.png"],
[UIImage imageNamed:@"record_animate_11.png"],
[UIImage imageNamed:@"record_animate_12.png"],
[UIImage imageNamed:@"record_animate_13.png"],
[UIImage imageNamed:@"record_animate_14.png"],
nil];
}
- (void)dealloc {
[peakImageAry release];
[_peakMeterIV release];
[_countDownLabel release];
[super dealloc];
}
#pragma mark -
- (void)restoreDisplay{
//
self.background.layer.masksToBounds = YES;
self.background.layer.cornerRadius = 8;
_peakMeterIV.image = [peakImageAry objectAtIndex:0];
//
_countDownLabel.text = @"";
}
#pragma mark -
- (void)updateMetersByAvgPower:(float)_avgPower{
//-1600
//
NSInteger imageIndex = 0;
if (_avgPower >= -56 && _avgPower < -52)
imageIndex = 1;
else if (_avgPower >= -52 && _avgPower < -48)
imageIndex = 2;
else if (_avgPower >= -48 && _avgPower < -44)
imageIndex = 3;
else if (_avgPower >= -44 && _avgPower < -40)
imageIndex = 4;
else if (_avgPower >= -40 && _avgPower < -36)
imageIndex = 5;
else if (_avgPower >= -36 && _avgPower < -34)
imageIndex = 6;
else if (_avgPower >= -34 && _avgPower < -30)
imageIndex = 7;
else if (_avgPower >= -30 && _avgPower < -26)
imageIndex = 8;
else if (_avgPower >= -26 && _avgPower < -22)
imageIndex = 9;
else if (_avgPower >= -22 && _avgPower < -18)
imageIndex = 10;
else if (_avgPower >= -18 && _avgPower < -14)
imageIndex = 11;
else if (_avgPower >= -14 && _avgPower < -10)
imageIndex = 12;
else if (_avgPower >= -10)
imageIndex = 13;
_peakMeterIV.image = [peakImageAry objectAtIndex:imageIndex];
}
@end

View File

@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11542" systemVersion="15G1108" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11524"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="2" customClass="ChatRecorderView">
<rect key="frame" x="0.0" y="0.0" width="125" height="130"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<view alpha="0.34999999403953552" contentMode="scaleToFill" id="10">
<rect key="frame" x="0.0" y="0.0" width="125" height="130"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" text="" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="7">
<rect key="frame" x="24" y="46" width="145" height="21"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" text="手指拿开,取消发送" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="11">
<rect key="frame" x="11" y="105" width="102" height="15"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<color key="textColor" cocoaTouchSystemColor="tableCellGroupedBackgroundColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" cocoaTouchSystemColor="darkTextColor"/>
</view>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" image="record_animate_01.png" id="3">
<rect key="frame" x="32" y="11" width="60" height="88"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</imageView>
</subviews>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="simulatedStatusBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<connections>
<outlet property="background" destination="10" id="12"/>
<outlet property="countDownLabel" destination="7" id="8"/>
<outlet property="peakMeterIV" destination="3" id="5"/>
</connections>
<point key="canvasLocation" x="192.5" y="271"/>
</view>
</objects>
<resources>
<image name="record_animate_01.png" width="75" height="111"/>
</resources>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
<simulatedScreenMetrics key="destination" type="retina4_7.fullscreen"/>
</simulatedMetricsContainer>
</document>

View File

@@ -0,0 +1,21 @@
//
// ChatVoiceRecorderVC.h
// Jeans
//
// Created by Jeans on 3/23/13.
// Copyright (c) 2013 Jeans. All rights reserved.
//
#import "VoiceRecorderBaseVC.h"
#define kRecorderViewRect CGRectMake(([[UIScreen mainScreen]bounds].size.width-125)/2, 98, 125, 130)
//#define kCancelOriginY (kRecorderViewRect.origin.y + kRecorderViewRect.size.height + 180)
#define kCancelOriginY ([[UIScreen mainScreen]bounds].size.width-70)
@interface ChatVoiceRecorderVC : VoiceRecorderBaseVC
//开始录音
- (void)beginRecordByFileName:(NSString*)_fileName;
@end

View File

@@ -0,0 +1,288 @@
//
// ChatVoiceRecorderVC.m
// Jeans
//
// Created by Jeans on 3/23/13.
// Copyright (c) 2013 Jeans. All rights reserved.
//
#import "ChatVoiceRecorderVC.h"
#import "UIView+Animation.h"
#import "ChatRecorderView.h"
@interface ChatVoiceRecorderVC ()<AVAudioRecorderDelegate>{
CGFloat curCount; //,0
ChatRecorderView *recorderView; //
CGPoint curTouchPoint; //
BOOL canNotSend; //
NSTimer *timer;
}
@property (retain, nonatomic) AVAudioRecorder *recorder;
@end
@implementation ChatVoiceRecorderVC
@synthesize recorder;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)dealloc{
[recorder release];
[recorderView release];
[super dealloc];
}
- (BOOL)canRecord
{
__block BOOL bCanRecord = YES;
if ([[[UIDevice currentDevice] systemVersion] compare:@"7.0"] != NSOrderedAscending)
{
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
if ([audioSession respondsToSelector:@selector(requestRecordPermission:)]) {
[audioSession performSelector:@selector(requestRecordPermission:) withObject:^(BOOL granted) {
if (granted) {
bCanRecord = YES;
} else {
bCanRecord = NO;
}
}];
}
}
return bCanRecord;
}
//-(int)ifauth
//{
// int flag;
// AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeAudio];
// switch (authStatus) {
// case AVAuthorizationStatusNotDetermined:
// //
// flag = 1;
// break;
// case AVAuthorizationStatusRestricted:
// //
// flag = 0;
// break;
// case AVAuthorizationStatusDenied:
// //
// flag = 0;
// break;
// case AVAuthorizationStatusAuthorized:
// //
// flag = 2;
// break;
// default:
// break;
// }
// return flag;
//}
#pragma mark -
- (void)beginRecordByFileName:(NSString*)_fileName;{
//
self.recordFileName = _fileName;
self.recordFilePath = [VoiceRecorderBaseVC getPathByFileName:recordFileName ofType:@"wav"];
//
self.recorder = [[[AVAudioRecorder alloc]initWithURL:[NSURL URLWithString:recordFilePath]
settings:[VoiceRecorderBaseVC getAudioRecorderSettingDict]
error:nil]autorelease];
recorder.delegate = self;
recorder.meteringEnabled = YES;
[recorder prepareToRecord];
//
curCount = 0;
//
canNotSend = NO;
//
[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayAndRecord error:nil];
[[AVAudioSession sharedInstance] setActive:YES error:nil];
[recorder record];
//
[self startTimer];
//
[self initRecordView];
[UIView showView:recorderView
animateType:AnimateTypeOfPopping
finalRect:kRecorderViewRect
completion:^(BOOL finish){
if (finish){
//nScreenTouch
[self addScreenTouchObserver];
}
}];
//
[UIView setTopMaskViewCanTouch:NO];
}
#pragma mark -
- (void)initRecordView{
if (recorderView == nil)
recorderView = (ChatRecorderView*)[[[[NSBundle mainBundle]loadNibNamed:@"ChatRecorderView" owner:self options:nil]lastObject]retain];
//
[recorderView restoreDisplay];
}
#pragma mark -
- (void)startTimer{
timer = [NSTimer scheduledTimerWithTimeInterval:0.1f target:self selector:@selector(updateMeters) userInfo:nil repeats:YES];
}
#pragma mark -
- (void)stopTimer{
if (timer && timer.isValid){
[timer invalidate];
timer = nil;
}
}
#pragma mark -
- (void)updateMeters{
if (recorder.isRecording){
//
[recorder updateMeters];
[recorderView updateMetersByAvgPower:[recorder averagePowerForChannel:0]];
// NSLog(@"峰值:%f",[recorder averagePowerForChannel:0]);
//
if (curCount >= maxRecordTime - 10 && curCount < maxRecordTime) {
//10
recorderView.countDownLabel.text = [NSString stringWithFormat:@"录音剩下:%d秒",(int)(maxRecordTime-curCount)];
}else if (curCount >= maxRecordTime){
//
[self touchEnded:curTouchPoint];
}
curCount += 0.1f;
}
}
#pragma mark -
- (void)removeScreenTouchObserver{
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"nScreenTouch" object:nil];//nScreenTouch
}
#pragma mark -
- (void)addScreenTouchObserver{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onScreenTouch:) name:@"nScreenTouch" object:nil];
}
-(void)onScreenTouch:(NSNotification *)notification {
UIEvent *event=[notification.userInfo objectForKey:@"data"];
NSSet *allTouches = event.allTouches;
//
if ((curTouchPoint.x == CGPointZero.x && curTouchPoint.y == CGPointZero.y) || allTouches.count == 1)
[self transferTouch:[allTouches anyObject]];
else{
//touch,touch
for (UITouch *touch in allTouches){
CGPoint prePoint = [touch previousLocationInView:nil];
if (prePoint.x == curTouchPoint.x && prePoint.y == curTouchPoint.y)
[self transferTouch:touch];
}
}
}
//
- (void)transferTouch:(UITouch*)_touch{
CGPoint point = [_touch locationInView:nil];
switch (_touch.phase) {
case UITouchPhaseBegan:
[self touchBegan:point];
break;
case UITouchPhaseMoved:
[self touchMoved:point];
break;
case UITouchPhaseCancelled:
case UITouchPhaseEnded:
[self touchEnded:point];
break;
default:
break;
}
}
#pragma mark -
- (void)touchBegan:(CGPoint)_point{
curTouchPoint = _point;
}
#pragma mark -
- (void)touchMoved:(CGPoint)_point{
curTouchPoint = _point;
//
// canNotSend = _point.y < kCancelOriginY ? YES : NO;
canNotSend=NO;
}
#pragma mark -
- (void)touchEnded:(CGPoint)_point{
//
[self stopTimer];
curTouchPoint = CGPointZero;
[self removeScreenTouchObserver];
[UIView hideViewByCompletion:^(BOOL finish){
//
if (recorder.isRecording)
[recorder stop];
if (canNotSend) {
//
[VoiceRecorderBaseVC deleteFileAtPath:recordFilePath];
}else{
//
if ([self.vrbDelegate respondsToSelector:@selector(VoiceRecorderBaseVCRecordFinish:fileName:)])
[self.vrbDelegate VoiceRecorderBaseVCRecordFinish:recordFilePath fileName:recordFileName];
}
}];
}
#pragma mark - AVAudioRecorder Delegate Methods
- (void)audioRecorderDidFinishRecording:(AVAudioRecorder *)recorder successfully:(BOOL)flag{
NSLog(@"录音停止");
[self stopTimer];
curCount = 0;
}
- (void)audioRecorderBeginInterruption:(AVAudioRecorder *)recorder{
NSLog(@"录音开始");
[self stopTimer];
curCount = 0;
}
- (void)audioRecorderEndInterruption:(AVAudioRecorder *)recorder withOptions:(NSUInteger)flags{
NSLog(@"录音中断");
[self stopTimer];
curCount = 0;
}
@end

View File

@@ -0,0 +1,127 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">1296</int>
<string key="IBDocument.SystemVersion">14C1514</string>
<string key="IBDocument.InterfaceBuilderVersion">6751</string>
<string key="IBDocument.AppKitVersion">1344.72</string>
<string key="IBDocument.HIToolboxVersion">757.30</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="NS.object.0">6736</string>
</object>
<array key="IBDocument.IntegratedClassDependencies">
<string>IBProxyObject</string>
<string>IBUIView</string>
</array>
<array key="IBDocument.PluginDependencies">
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</array>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<string key="NS.key.0">PluginDependencyRecalculationVersion</string>
<integer value="1" key="NS.object.0"/>
</object>
<array class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
<object class="IBProxyObject" id="372490531">
<string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
<object class="IBProxyObject" id="975951072">
<string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
<object class="IBUIView" id="191373211">
<nil key="NSNextResponder"/>
<int key="NSvFlags">274</int>
<string key="NSFrame">{{0, 20}, {320, 460}}</string>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
<object class="NSColorSpace" key="NSCustomColorSpace">
<int key="NSID">2</int>
</object>
</object>
<object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/>
<object class="IBUIScreenMetrics" key="IBUISimulatedDestinationMetrics">
<string key="IBUISimulatedSizeMetricsClass">IBUIScreenMetrics</string>
<string key="IBUITargetRuntime">IBCocoaTouchFramework</string>
<string key="IBUIDisplayName">iPhone 3.5-inch</string>
<object class="NSMutableDictionary" key="IBUINormalizedOrientationToSizeMap">
<bool key="EncodedWithXMLCoder">YES</bool>
<array key="dict.sortedKeys">
<integer value="1"/>
<integer value="3"/>
</array>
<array key="dict.values">
<string>{320, 480}</string>
<string>{480, 320}</string>
</array>
</object>
<int key="IBUIType">0</int>
</object>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
</array>
<object class="IBObjectContainer" key="IBDocument.Objects">
<array key="connectionRecords">
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">view</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="191373211"/>
</object>
<int key="connectionID">3</int>
</object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
<object class="IBObjectRecord">
<int key="objectID">0</int>
<array key="object" id="0"/>
<reference key="children" ref="1000"/>
<nil key="parent"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">1</int>
<reference key="object" ref="191373211"/>
<array class="NSMutableArray" key="children"/>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">-1</int>
<reference key="object" ref="372490531"/>
<reference key="parent" ref="0"/>
<string key="objectName">File's Owner</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-2</int>
<reference key="object" ref="975951072"/>
<reference key="parent" ref="0"/>
</object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
<string key="-1.CustomClassName">ChatVoiceRecorderVC</string>
<string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="-2.CustomClassName">UIResponder</string>
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">4</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes"/>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
<bool key="IBDocument.previouslyAttemptedUpgradeToXcode5">NO</bool>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3</string>
<integer value="4600" key="NS.object.0"/>
</object>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
</data>
</archive>

View File

@@ -0,0 +1,13 @@
//
// CustomWindow.h
// AmrConvertAndRecord
//
// Created by Jeans on 3/29/13.
// Copyright (c) 2013 Jeans. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface CustomWindow : UIWindow
@end

View File

@@ -0,0 +1,37 @@
//
// CustomWindow.m
// AmrConvertAndRecord
//
// Created by Jeans on 3/29/13.
// Copyright (c) 2013 Jeans. All rights reserved.
//
#import "CustomWindow.h"
@implementation CustomWindow
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}
-(void)sendEvent:(UIEvent *)event {
@try {
if (event.type == UIEventTypeTouches) {//nScreenTouch
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:@"nScreenTouch" object:nil userInfo:[NSDictionary dictionaryWithObject:event forKey:@"data"]]];
}
[super sendEvent:event];
} @catch (NSException *exception) {
NSLog(@"%@",exception);
} @finally {
NSLog(@"@finally");
}
}
@end

View File

@@ -0,0 +1,56 @@
//
// UIView+Animation.h
//
//
// Created by Jeans on 3/9/13.
// Copyright (c) 2013 Jeans. All rights reserved.
//
#import <UIKit/UIKit.h>
#define kDefaultAnimateTime 0.25f
typedef enum AnimateType{ //动画类型
AnimateTypeOfTV, //电视
AnimateTypeOfPopping, //弹性缩小放大
AnimateTypeOfLeft, //左
AnimateTypeOfRight, //右
AnimateTypeOfTop, //上
AnimateTypeOfBottom //下
}AnimateType;
@interface UIView (Animation)
#pragma mark - 获取顶部View
+ (UIView *)getTopView;
#pragma mark - 顶层maskView触摸
+ (void)setTopMaskViewCanTouch:(BOOL)_canTouch;
/**
显示view
@param _view 需要显示的view
@param _aType 动画类型
@param _fRect 最终位置
*/
+ (void)showView:(UIView*)_view animateType:(AnimateType)_aType finalRect:(CGRect)_fRect;
/**
消失view
*/
+ (void)hideView;
/**
消失view
@param _aType 动画类型
*/
+ (void)hideViewByType:(AnimateType)_aType;
#pragma mark - 下面的增加了完成块
+ (void)showView:(UIView*)_view animateType:(AnimateType)_aType finalRect:(CGRect)_fRect completion:(void(^)(BOOL finished))completion;
+ (void)hideViewByCompletion:(void(^)(BOOL finished))completion;
+ (void)hideViewByType:(AnimateType)_aType completion:(void(^)(BOOL finished))completion;
@end

View File

@@ -0,0 +1,286 @@
//
// UIView+Animation.m
//
//
// Created by Jeans on 3/9/13.
// Copyright (c) 2013 Jeans. All rights reserved.
//
#import "UIView+Animation.h"
#import "AppDelegate.h"
#define kScaleMin 0.007f
#define kScaleDefault 1.0f
#define kScaleDelta 0.05f
#define kFirstAnimateTime 0.3f
#define kSecondAnimateTime 0.2f
#define kMaskViewFinalAlpha 0.2f //
@interface ViewInfo : NSObject{
AnimateType aType; //
UIView *displayView; //
CGRect displayRect; //
UIControl *maskView; //
void (^showBlock)(BOOL finished);
void (^hideBlock)(BOOL finished);
}
@property (retain, nonatomic) UIView *displayView;
@property (assign, nonatomic) AnimateType aType;
@property (assign, nonatomic) CGRect displayRect;
@property (retain, nonatomic) UIControl *maskView;
@property (copy, nonatomic) void (^showBlock)(BOOL finished);
@property (copy, nonatomic) void (^hideBlock)(BOOL finished);
@end
@implementation ViewInfo
@synthesize displayView,aType,maskView,displayRect,showBlock,hideBlock;
- (void)dealloc{
Block_release(hideBlock);
Block_release(showBlock);
[maskView release];
[displayView release];
[super dealloc];
}
@end
@implementation UIView (Animation)
static NSMutableArray *displayViewAry;//
#pragma mark - View
+ (AppDelegate *)getAppDelegate {
return (AppDelegate *)[[UIApplication sharedApplication] delegate];
}
+ (UIView *)getTopView{
return [[UIApplication sharedApplication].windows objectAtIndex:0];
// return [FuncPublic SharedFuncPublic].currentVC.view;
return [[[UIView getAppDelegate] root] view];
}
#pragma mark - maskView
+ (void)setTopMaskViewCanTouch:(BOOL)_canTouch{
ViewInfo *info = [displayViewAry lastObject];
if (_canTouch)
[info.maskView addTarget:self action:@selector(maskViewTouch) forControlEvents:UIControlEventTouchUpInside];
else
[info.maskView removeTarget:self action:@selector(maskViewTouch) forControlEvents:UIControlEventTouchUpInside];
}
#pragma mark -
/**
view
@param _view view
@param _aType
@param _fRect
@param completion
*/
+ (void)showView:(UIView*)_view animateType:(AnimateType)_aType finalRect:(CGRect)_fRect completion:(void(^)(BOOL finished))completion{
//
if (displayViewAry == nil)
displayViewAry = [[NSMutableArray alloc]init];
UIView *topView = [UIView getTopView];
//
ViewInfo *info = [[ViewInfo alloc]init];
info.displayView = _view;
info.aType = _aType;
info.displayRect = _fRect;
//
UIControl *maskView = [[UIControl alloc]init];
maskView.backgroundColor = [UIColor blackColor];
maskView.alpha = 0;
maskView.frame = topView.bounds;
[maskView addTarget:self action:@selector(maskViewTouch) forControlEvents:UIControlEventTouchUpInside];
//
[topView addSubview:maskView];
[topView bringSubviewToFront:maskView];
info.maskView = maskView;
[maskView release];
if (completion)
info.showBlock = completion;
[displayViewAry addObject:info];
[info release];
//
switch (_aType) {
case AnimateTypeOfTV:
[UIView showTV];
break;
case AnimateTypeOfPopping:
[UIView showPopping];
default:
break;
}
}
/**
view
@param _view view
@param _aType
@param _fRect
*/
+ (void)showView:(UIView*)_view animateType:(AnimateType)_aType finalRect:(CGRect)_fRect{
[self showView:_view animateType:_aType finalRect:_fRect completion:nil];
}
#pragma mark - view
+ (void)hideViewByCompletion:(void(^)(BOOL finished))completion{
if ([displayViewAry count] > 0){
ViewInfo *info = [displayViewAry lastObject];
if (completion)
info.hideBlock = completion;
}
[UIView maskViewTouch];
}
+ (void)hideViewByType:(AnimateType)_aType completion:(void(^)(BOOL finished))completion{
if ([displayViewAry count] > 0){
ViewInfo *info = [displayViewAry lastObject];
info.aType = _aType;
if (completion)
info.hideBlock = completion;
}
[UIView maskViewTouch];
}
//
+ (void)hideView{
[UIView hideViewByCompletion:nil];
}
+ (void)hideViewByType:(AnimateType)_aType{
[UIView hideViewByType:_aType completion:nil];
}
#pragma mark -
+ (void)maskViewTouch{
if ([displayViewAry count] > 0){
ViewInfo *info = [displayViewAry lastObject];
//
switch (info.aType) {
case AnimateTypeOfTV:
[UIView hideTV];
break;
case AnimateTypeOfPopping:
[UIView hidePopping];
break;
default:
break;
}
}
}
#pragma mark -
+ (void)removeMaskViewAndDisplay:(ViewInfo*)info{
if (info.aType == AnimateTypeOfTV || info.aType == AnimateTypeOfPopping) //TV,Popping
info.displayView.transform = CGAffineTransformMakeScale(kScaleDefault, kScaleDefault);
[info.displayView removeFromSuperview];
[info.maskView removeFromSuperview];
[displayViewAry removeObject:info];
}
#pragma mark -
#pragma mark - TV
+ (void)showTV{
ViewInfo *info = [displayViewAry lastObject];
UIView *topView = [UIView getTopView];
info.displayView.frame = info.displayRect;
[topView addSubview:info.displayView];
[topView bringSubviewToFront:info.displayView];
info.displayView.transform = CGAffineTransformMakeScale(kScaleMin, kScaleMin);
//
[UIView animateWithDuration:kSecondAnimateTime animations:^{
info.maskView.alpha = 0.1f;
info.displayView.transform = CGAffineTransformMakeScale(kScaleDefault, kScaleMin);
}completion:^(BOOL finish){
[UIView animateWithDuration:kFirstAnimateTime animations:^{
info.maskView.alpha = kMaskViewFinalAlpha;
info.displayView.transform = CGAffineTransformMakeScale(kScaleDefault, kScaleDefault);
}completion:^(BOOL finish){
//
if (info.showBlock)
info.showBlock(finish);
}];
}];
}
#pragma mark - TV
+ (void)hideTV{
ViewInfo *info = [displayViewAry lastObject];
[UIView animateWithDuration:kSecondAnimateTime animations:^{
info.displayView.transform = CGAffineTransformMakeScale(kScaleDefault, kScaleMin);
}completion:^(BOOL finish){
[UIView animateWithDuration:kFirstAnimateTime animations:^{
info.displayView.transform = CGAffineTransformMakeScale(kScaleMin, kScaleMin);
info.maskView.alpha = 0;
}completion:^(BOOL finish){
//
if (info.hideBlock)
info.hideBlock(finish);
[UIView removeMaskViewAndDisplay:info];
}];
}];
}
#pragma mark - Popping
+ (void)showPopping{
ViewInfo *info = [displayViewAry lastObject];
UIView *topView = [UIView getTopView];
info.displayView.frame = info.displayRect;
[topView addSubview:info.displayView];
[topView bringSubviewToFront:info.displayView];
info.displayView.transform = CGAffineTransformMakeScale(kScaleMin, kScaleMin);
//
[UIView animateWithDuration:kFirstAnimateTime animations:^{
info.maskView.alpha = kMaskViewFinalAlpha;
info.displayView.transform = CGAffineTransformMakeScale(kScaleDefault+kScaleDelta, kScaleDefault+kScaleDelta);
}completion:^(BOOL finish){
[UIView animateWithDuration:kSecondAnimateTime animations:^{
info.displayView.transform = CGAffineTransformMakeScale(kScaleDefault-kScaleDelta, kScaleDefault-kScaleDelta);
}completion:^(BOOL finish){
[UIView animateWithDuration:kSecondAnimateTime animations:^{
info.displayView.transform = CGAffineTransformMakeScale(kScaleDefault, kScaleDefault);
}completion:^(BOOL finish){
//
if (info.showBlock)
info.showBlock(finish);
}];
}];
}];
}
#pragma mark - Popping
+ (void)hidePopping{
ViewInfo *info = [displayViewAry lastObject];
[UIView animateWithDuration:kFirstAnimateTime animations:^{
info.maskView.alpha = 0;
info.displayView.transform = CGAffineTransformMakeScale(kScaleMin, kScaleMin);
}completion:^(BOOL finish){
//
if (info.hideBlock)
info.hideBlock(finish);
[UIView removeMaskViewAndDisplay:info];
}];
}
@end

View File

@@ -0,0 +1,81 @@
//
// VoiceRecorderBaseVC.h
// Jeans
//
// Created by Jeans on 3/23/13.
// Copyright (c) 2013 Jeans. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "AudioToolbox/AudioToolbox.h"
#import <AVFoundation/AVFoundation.h>
#import <CoreAudio/CoreAudioTypes.h>
//默认最大录音时间
#define kDefaultMaxRecordTime 60
@protocol VoiceRecorderBaseVCDelegate <NSObject>
//录音完成回调,返回文件路径和文件名
- (void)VoiceRecorderBaseVCRecordFinish:(NSString *)_filePath fileName:(NSString*)_fileName;
@end
@interface VoiceRecorderBaseVC : UIViewController{
@protected
NSInteger maxRecordTime; //最大录音时间
NSString *recordFileName;//录音文件名
NSString *recordFilePath;//录音文件路径
}
@property (assign, nonatomic) id<VoiceRecorderBaseVCDelegate> vrbDelegate;
@property (assign, nonatomic) NSInteger maxRecordTime;//最大录音时间
@property (copy, nonatomic) NSString *recordFileName;//录音文件名
@property (copy, nonatomic) NSString *recordFilePath;//录音文件路径
/**
生成当前时间字符串
@returns 当前时间字符串
*/
+ (NSString*)getCurrentTimeString;
/**
获取缓存路径
@returns 缓存路径
*/
+ (NSString*)getCacheDirectory;
/**
判断文件是否存在
@param _path 文件路径
@returns 存在返回yes
*/
+ (BOOL)fileExistsAtPath:(NSString*)_path;
/**
删除文件
@param _path 文件路径
@returns 成功返回yes
*/
+ (BOOL)deleteFileAtPath:(NSString*)_path;
#pragma mark -
/**
生成文件路径
@param _fileName 文件名
@param _type 文件类型
@returns 文件路径
*/
+ (NSString*)getPathByFileName:(NSString *)_fileName;
+ (NSString*)getPathByFileName:(NSString *)_fileName ofType:(NSString *)_type;
/**
获取录音设置
@returns 录音设置
*/
+ (NSDictionary*)getAudioRecorderSettingDict;
@end

View File

@@ -0,0 +1,132 @@
//
// VoiceRecorderBaseVC.m
// Jeans
//
// Created by Jeans on 3/23/13.
// Copyright (c) 2013 Jeans. All rights reserved.
//
#import "VoiceRecorderBaseVC.h"
@interface VoiceRecorderBaseVC ()
@end
@implementation VoiceRecorderBaseVC
@synthesize vrbDelegate,maxRecordTime,recordFileName,recordFilePath;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
maxRecordTime = kDefaultMaxRecordTime;
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)dealloc{
[recordFilePath release];
[recordFileName release];
[super dealloc];
}
/**
@returns
*/
+ (NSString*)getCurrentTimeString
{
NSDateFormatter *dateformat=[[[NSDateFormatter alloc]init]autorelease];
[dateformat setDateFormat:@"yyyyMMddHHmmss"];
return [dateformat stringFromDate:[NSDate date]];
}
/**
@returns
*/
+ (NSString*)getCacheDirectory
{
return [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)objectAtIndex:0];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
return [[paths objectAtIndex:0]stringByAppendingPathComponent:@"Voice"];
}
/**
@param _path
@returns yes
*/
+ (BOOL)fileExistsAtPath:(NSString*)_path
{
return [[NSFileManager defaultManager] fileExistsAtPath:_path];
}
/**
@param _path
@returns yes
*/
+ (BOOL)deleteFileAtPath:(NSString*)_path
{
return [[NSFileManager defaultManager] removeItemAtPath:_path error:nil];
}
/**
@param _fileName
@param _type
@returns
*/
+ (NSString*)getPathByFileName:(NSString *)_fileName ofType:(NSString *)_type
{
NSString* fileDirectory = [[[VoiceRecorderBaseVC getCacheDirectory]stringByAppendingPathComponent:_fileName]stringByAppendingPathExtension:_type];
return fileDirectory;
}
/**
@param _fileName
@returns
*/
+ (NSString*)getPathByFileName:(NSString *)_fileName{
NSString* fileDirectory = [[VoiceRecorderBaseVC getCacheDirectory]stringByAppendingPathComponent:_fileName];
return fileDirectory;
}
/**
@returns
*/
+ (NSDictionary*)getAudioRecorderSettingDict
{
NSDictionary *recordSetting = [[NSDictionary alloc] initWithObjectsAndKeys:
[NSNumber numberWithFloat: 8000.0],AVSampleRateKey, //
[NSNumber numberWithInt: kAudioFormatLinearPCM],AVFormatIDKey,
[NSNumber numberWithInt:16],AVLinearPCMBitDepthKey,// 16
[NSNumber numberWithInt: 1], AVNumberOfChannelsKey,//
// [NSNumber numberWithBool:NO],AVLinearPCMIsBigEndianKey,//
// [NSNumber numberWithBool:NO],AVLinearPCMIsFloatKey,//
// [NSNumber numberWithInt: AVAudioQualityMedium],AVEncoderAudioQualityKey,//
nil];
return [recordSetting autorelease];
}
@end

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB