小编Mc.*_*ver的帖子

如何屏蔽UIImageView?

我试图用这样的东西掩盖图像:

图像被掩盖

你能帮帮我吗?

我正在使用此代码:

- (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)

mask objective-c uiimage ios

96
推荐指数
6
解决办法
7万
查看次数

如何使用UIStepper

我正在努力UIStepper增加或减少一个整数,但" - "和"+"都会增加整数!如何识别"+"和" - "按钮?

UIStepper头文件中有两个UIButtons:

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)

objective-c ios uistepper

39
推荐指数
1
解决办法
7万
查看次数

为UILabel iphone创建文本笔划

我想知道如何在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 ios4

29
推荐指数
1
解决办法
1万
查看次数

将iPhone应用程序转换为Xcode 4中的通用应用程序

我正在尝试将我现有的iPhone应用程序项目升级到通用应用程序,但我在Xcode 4中找不到任何选项来执行此操作.它在哪里?

objective-c universal-binary ios xcode4

25
推荐指数
2
解决办法
2万
查看次数

MapKit缩放到用户当前位置

我试图简单地在地图上显示用户的位置,但是我需要在应用程序启动时,地图应该缩放到当前位置,但我不知道为什么地图根本不会缩放,它是这样的:

在此输入图像描述

这是代码:

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)

iphone xcode mapkit ios swift

20
推荐指数
3
解决办法
4万
查看次数

iPad Pro设备检测

我正在尝试检测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!

谢谢

编辑:有人建议使用LunchScreen,但是当我使用它时,会发生这种情况(按比例缩小): 在此输入图像描述

objective-c ipad ios

19
推荐指数
5
解决办法
1万
查看次数

iOS:使用自定义分辨率保存图像

嗨我尝试捕获视图然后将图像另存为照片库,但我需要为捕获的图像创建自定义分辨率,这是我的代码但是当应用程序保存图像时分辨率很低!

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

如果你能帮助我解决这个问题,我将不胜感激.

iphone xcode objective-c ipad ios

15
推荐指数
2
解决办法
2万
查看次数

iOS徽章编号实时更新

我为iOS创建了一个自定义日历,我正在尝试使用徽章编号来显示当天的编号,但是在一天过后数字没有变化,我的意思是他们应该更新热闹这里是我的代码:我需要类似天气实时应用程序的东西,此应用程序不发送任何推送通知!

    int a = [DateComponents showDay];
    [UIApplication sharedApplication].applicationIconBadgeNumber = a ;
Run Code Online (Sandbox Code Playgroud)

iphone sdk xcode ipad ios

14
推荐指数
1
解决办法
1万
查看次数

将CGcolorRef转换为UIColor

我想知道怎么能转换CGcolorRefUIColor?我为自己创建了一个自定义方法,我需要它来使用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 xcode objective-c ios

14
推荐指数
2
解决办法
2万
查看次数

在模拟器上检测iPhone 6/Plus时遇到问题

我正在尝试专门为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)

iphone xcode objective-c ios

14
推荐指数
1
解决办法
1万
查看次数

标签 统计

ios ×9

objective-c ×7

iphone ×6

xcode ×5

ipad ×3

ios4 ×1

mapkit ×1

mask ×1

sdk ×1

swift ×1

uiimage ×1

uistepper ×1

universal-binary ×1

xcode4 ×1