-(UIImage*)loadImageFromUrl:(NSString*)url
{
NSURL *picUrl = [NSURL URLWithString:url];
NSData *picData = [NSData dataWithContentsOfURL:picUrl];
UIImage *p_w_picpath = [UIImage p_w_picpathWithData:picData];
return p_w_picpath;
}
然后你的UIImageView.imge =这返回的图片
如果页面已经呈现了,你的UiImageView调用setNeedsDisplay方法就可以刷新了
iphone中怎么把button做成圆形的
UIImage *p_w_picpath = [UIImage p_w_picpathNamed:@"xxx.png"];
[button setBackgroundImage:p_w_picpath forState:UIControlStateNormal];
图片选张圆型的就可以了
如果在xib中拖出来的按钮,就把Type设为custom,然后在BackImage里选张圆型图片
这图片需要事先添加进Resources里
#define kImageWidth 303
#define kImageHeight 58
#define kImageCount 6
@protocol WelComeDelegate;
@interface WelComeViewController : UIViewController
{
UIImageView* p_w_picpathsView;
NSMutableArray* p_w_picpathList;
id<WelComeDelegate> m_delegate;
NSTimer* m_timer;
}
@property(nonatomic,retain)NSTimer* m_timer;
@property(nonatomic,retain)UIImageView* p_w_picpathsView;
@property(nonatomic,retain)NSMutableArray* p_w_picpathList;
@property (nonatomic, assign) id <WelComeDelegate> m_delegate;
-(void)displayImage:(NSArray*)p_w_picpaths;
-(void)displayImage;
@end
@protocol WelComeDelegate
- (void)animateDidFinish;
@end
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardDidShowNotification
object:nil];
)- (void)keyboardWillShow:(NSNotification *)note {
// create custom button
UIButton *doneButton = [UIButton buttonWithType:UIButtonTypeCustom];
doneButton.frame = CGRectMake(0, 163, 106, 53);
doneButton.adjustsImageWhenHighlighted = NO;
[doneButton setImage:[UIImage p_w_picpathNamed:@"DoneUp.png"] forState:UIControlStateNormal];
[doneButton setImage:[UIImage p_w_picpathNamed:@"DoneDown.png"] forState:UIControlStateHighlighted];
[doneButton addTarget:self action:@selector(doneButton:) forControlEvents:UIControlEventTouchUpInside];
// locate keyboard view
UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];
UIView* keyboard;
for(int i=0; i<[tempWindow.subviews count]; i++) {
keyboard = [tempWindow.subviews objectAtIndex:i];
// keyboard view found; add the custom button to it
if(([[keyboard description] hasPrefix:@"<UIPeripheralHostView"] == YES) ||(([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES)))
[keyboard addSubview:doneButton];
}
}
2。头文件
#import <AVFoundation/AVFoundation.h>
AVAudioPlayer *audioPlayer;
NSString *name =[[NSString alloc]initWithFormat:@"1-welcome"];//the name of your music file
NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:name ofType:@"wav"];
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:soundFilePath];
AVAudioPlayer *myaudioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error :nil];
[myaudioPlayer play];
[fileURL release];
记得释放autoPlayer