我试图用这样的东西掩盖图像:
你能帮帮我吗?
我正在使用此代码:
- (void) viewDidLoad {
UIImage *OrigImage = [UIImage imageNamed:@"dogs.png"];
UIImage *mask = [UIImage imageNamed:@"mask.png"];
UIImage *maskedImage = [self maskImage:OrigImage withMask:mask];
myUIIMage.image = maskedImage;
}
Run Code Online (Sandbox Code Playgroud) 我正在努力UIStepper
增加或减少一个整数,但" - "和"+"都会增加整数!如何识别"+"和" - "按钮?
在UIStepper
头文件中有两个UIButton
s:
UIButton *_plusButton;
UIButton *_minusButton;
Run Code Online (Sandbox Code Playgroud)
例如 :
- (IBAction)changeValue:(id)sender
{
UIStepper *stepper = (UIStepper *) sender;
stepper.maximumValue = 10;
stepper.minimumValue = 0;
if (stepper)
{
integer++;
[label setText:[NSString stringWithFormat:@"%d",integer]];
}
else
{
integer--;
[label setText:[NSString stringWithFormat:@"%d",integer]];
}
}
Run Code Online (Sandbox Code Playgroud) 我想知道如何在iOS4中为UILabel创建文本笔划?我需要一些建议.我想要这样的东西:
编辑:
UIFont *font = [UIFont fontWithName:@"Arial" size:222];
CGPoint point = CGPointMake(0,0);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 0.7);
CGContextSetRGBStrokeColor(context, 2, 2, 2, 1.0);
CGContextSetTextDrawingMode(context, kCGTextFillStroke);
CGContextSaveGState(context);
// I change it to my outlet
[label.text drawAtPoint:point withFont:font];
CGContextRestoreGState(context);
Run Code Online (Sandbox Code Playgroud) 我正在尝试将我现有的iPhone应用程序项目升级到通用应用程序,但我在Xcode 4中找不到任何选项来执行此操作.它在哪里?
我试图简单地在地图上显示用户的位置,但是我需要在应用程序启动时,地图应该缩放到当前位置,但我不知道为什么地图根本不会缩放,它是这样的:
这是代码:
class MapViewController: UIViewController, CLLocationManagerDelegate, MKMapViewDelegate {
@IBOutlet weak var mapView: MKMapView!
var locationManager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
mapView.delegate = self
mapView.showsUserLocation = true
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestWhenInUseAuthorization()
locationManager.delegate = self
DispatchQueue.main.async {
self.locationManager.startUpdatingLocation()
}
}
func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) {
let location = locations.last as! CLLocation
let center = CLLocationCoordinate2D(latitude: location.coordinate.latitude, longitude: location.coordinate.longitude)
var region = MKCoordinateRegion(center: center, span: MKCoordinateSpan(latitudeDelta: 0.1, longitudeDelta: 0.1))
region.center = mapView.userLocation.coordinate
mapView.setRegion(region, animated: true)
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试检测iPad Pro设备,试图用以下方法猜测它的高度:
NSLog(@"%f",self.view.frame.size.height);
Run Code Online (Sandbox Code Playgroud)
但它又回来了1024
!与iPad非视网膜设备相同.任何建议?
我需要使用以下代码行为iPad Pro指定一些代码:
#define iPadPro ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad && [UIScreen mainScreen].bounds.size.height == 2732)
Run Code Online (Sandbox Code Playgroud)
...即使在iOS模拟器上,代码也必须检测iPad Pro!
谢谢
嗨我尝试捕获视图然后将图像另存为照片库,但我需要为捕获的图像创建自定义分辨率,这是我的代码但是当应用程序保存图像时分辨率很低!
UIGraphicsBeginImageContextWithOptions(self.captureView.bounds.size, self.captureView.opaque, 0.0);
[self.captureView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage * screenshot = UIGraphicsGetImageFromCurrentImageContext();
CGRect cropRect = CGRectMake(0 ,0 ,1435 ,1435);
CGImageRef imageRef = CGImageCreateWithImageInRect([screenshot CGImage], cropRect);
CGImageRelease(imageRef);
UIImageWriteToSavedPhotosAlbum(screenshot , nil, nil, nil);
UIGraphicsEndImageContext();
Run Code Online (Sandbox Code Playgroud)
但iPhone的分辨率为:320 x 320,视网膜为:640 x 640
如果你能帮助我解决这个问题,我将不胜感激.
我为iOS创建了一个自定义日历,我正在尝试使用徽章编号来显示当天的编号,但是在一天过后数字没有变化,我的意思是他们应该更新热闹这里是我的代码:我需要类似天气实时应用程序的东西,此应用程序不发送任何推送通知!
int a = [DateComponents showDay];
[UIApplication sharedApplication].applicationIconBadgeNumber = a ;
Run Code Online (Sandbox Code Playgroud) 我想知道怎么能转换CGcolorRef
成UIColor
?我为自己创建了一个自定义方法,我需要它来使用UIColor
编辑方法:
- (void)fontColor:(CGColorRef)colors setString(NSSTring *)blah blah blah {
coreTextLayer.foregroundColor = color;
}
[myClass fontColor:[UIColor redColor] setString....];
Run Code Online (Sandbox Code Playgroud)
正确的方法是使用这样的东西:
[UIColor redColor]CGColor];
Run Code Online (Sandbox Code Playgroud)
但有没有办法只使用UIColor?
我正在尝试专门为iPhone 6和6 Plus构建我的应用程序版本,而我没有任何硬件,我必须在模拟器上进行测试!但似乎,模拟器有一个奇怪的错误!首先,我通过以下代码获得屏幕分辨率和比例:
UIScreen *mainScreen = [UIScreen mainScreen];
NSLog(@"Screen bounds: %@, Screen resolution: %@, scale: %f, nativeScale: %f",
NSStringFromCGRect(mainScreen.bounds), mainScreen.coordinateSpace, mainScreen.scale, mainScreen.nativeScale);
Run Code Online (Sandbox Code Playgroud)
所以这里是如何检测iPhone 6和6Plus(纵向模式):
#define iPhone6 ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone && [UIScreen mainScreen].bounds.size.height == 667)
#define iPhone6Plus ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone && [UIScreen mainScreen].bounds.size.height == 736)
Run Code Online (Sandbox Code Playgroud)
问题是 !当我在iPhone6/Plus模拟器上吃午餐时,编译器会给我一些iPhone 4"显示屏的信息:
2014-09-28 12:32:08.153 WOD[2924:42290]
Screen bounds: {{0, 0}, {320, 568}}, Screen resolution: <UIScreen: 0x7fa15be0f9b0; bounds = {{0, 0}, {320, 568}}; mode = <UIScreenMode: 0x7fa15bd0d4a0;
size = 640.000000 x 1136.000000>>, scale: …
Run Code Online (Sandbox Code Playgroud)